Skip to content

Commit 89d546f

Browse files
author
Michael Johns
committed
style(python): satisfy isort + black for PR lint gate
CI surfaced one isort failure (test_sample_bundle.py — `_bundle as _bundle_mod` had to sort before the multiline `from … import (…)` because `_` precedes letters in isort's ordering). Once that's fixed, black also wants to reformat three pre-existing files where short signatures had been unnecessarily split across multiple lines: src/databricks/labs/gbx/gridx/bng/functions.py (3 fn signatures) src/databricks/labs/gbx/rasterx/functions.py (1 fn signature) test/gridx/test_bng_functions.py (mechanical) These are pure reformats — no behavior change. Verified locally with the pinned versions from requirements-ci.in (isort==8.0.1, black==26.3.1, flake8==7.3.0). All 26 .py files under src/ and test/ now pass all three gates cleanly. In test_sample_bundle.py, also replaced the previous pair of mis- ordered comments above the imports with a single accurate comment; isort's auto-fix had stacked both comments above the `_bundle_mod` line, leaving "Public API from package" attached to the wrong import. Co-authored-by: Isaac
1 parent c265d5f commit 89d546f

4 files changed

Lines changed: 19 additions & 43 deletions

File tree

python/geobrix/src/databricks/labs/gbx/gridx/bng/functions.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ def bng_euclideandistance(cell_id1: ColLike, cell_id2: ColLike) -> Column:
160160
Returns:
161161
Column of long (distance in metres).
162162
"""
163-
return f.call_function(
164-
"gbx_bng_euclideandistance", _col(cell_id1), _col(cell_id2)
165-
)
163+
return f.call_function("gbx_bng_euclideandistance", _col(cell_id1), _col(cell_id2))
166164

167165

168166
def bng_geomkloop(geom: ColLike, resolution: ColLike, k: ColLike) -> Column:
@@ -176,9 +174,7 @@ def bng_geomkloop(geom: ColLike, resolution: ColLike, k: ColLike) -> Column:
176174
Returns:
177175
Column of array of BNG cell identifiers.
178176
"""
179-
return f.call_function(
180-
"gbx_bng_geomkloop", _col(geom), _col(resolution), _col(k)
181-
)
177+
return f.call_function("gbx_bng_geomkloop", _col(geom), _col(resolution), _col(k))
182178

183179

184180
def bng_geomkring(geom: ColLike, resolution: ColLike, k: ColLike) -> Column:
@@ -192,9 +188,7 @@ def bng_geomkring(geom: ColLike, resolution: ColLike, k: ColLike) -> Column:
192188
Returns:
193189
Column of array of BNG cell identifiers.
194190
"""
195-
return f.call_function(
196-
"gbx_bng_geomkring", _col(geom), _col(resolution), _col(k)
197-
)
191+
return f.call_function("gbx_bng_geomkring", _col(geom), _col(resolution), _col(k))
198192

199193

200194
def bng_kloop(cell_id: ColLike, k: ColLike) -> Column:

python/geobrix/src/databricks/labs/gbx/rasterx/functions.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,7 @@ def rst_combineavg_agg(tile: ColLike) -> Column:
412412
return f.call_function("gbx_rst_combineavg_agg", _col(tile))
413413

414414

415-
def rst_derivedband_agg(
416-
tile: ColLike, pyfunc: ColLike, func_name: ColLike
417-
) -> Column:
415+
def rst_derivedband_agg(tile: ColLike, pyfunc: ColLike, func_name: ColLike) -> Column:
418416
"""Aggregate tiles and apply a Python UDF per band (use with groupBy).
419417
420418
Args:
@@ -576,9 +574,7 @@ def rst_h3_rastertogridavg(tile: ColLike, resolution: ColLike) -> Column:
576574
Returns:
577575
Column of grid values (e.g. struct with H3 index and avg).
578576
"""
579-
return f.call_function(
580-
"gbx_rst_h3_rastertogridavg", _col(tile), _col(resolution)
581-
)
577+
return f.call_function("gbx_rst_h3_rastertogridavg", _col(tile), _col(resolution))
582578

583579

584580
def rst_h3_rastertogridcount(tile: ColLike, resolution: ColLike) -> Column:
@@ -591,9 +587,7 @@ def rst_h3_rastertogridcount(tile: ColLike, resolution: ColLike) -> Column:
591587
Returns:
592588
Column of grid values (e.g. struct with H3 index and count).
593589
"""
594-
return f.call_function(
595-
"gbx_rst_h3_rastertogridcount", _col(tile), _col(resolution)
596-
)
590+
return f.call_function("gbx_rst_h3_rastertogridcount", _col(tile), _col(resolution))
597591

598592

599593
def rst_h3_rastertogridmax(tile: ColLike, resolution: ColLike) -> Column:
@@ -606,9 +600,7 @@ def rst_h3_rastertogridmax(tile: ColLike, resolution: ColLike) -> Column:
606600
Returns:
607601
Column of grid values (e.g. struct with H3 index and max).
608602
"""
609-
return f.call_function(
610-
"gbx_rst_h3_rastertogridmax", _col(tile), _col(resolution)
611-
)
603+
return f.call_function("gbx_rst_h3_rastertogridmax", _col(tile), _col(resolution))
612604

613605

614606
def rst_h3_rastertogridmin(tile: ColLike, resolution: ColLike) -> Column:
@@ -621,9 +613,7 @@ def rst_h3_rastertogridmin(tile: ColLike, resolution: ColLike) -> Column:
621613
Returns:
622614
Column of grid values (e.g. struct with H3 index and min).
623615
"""
624-
return f.call_function(
625-
"gbx_rst_h3_rastertogridmin", _col(tile), _col(resolution)
626-
)
616+
return f.call_function("gbx_rst_h3_rastertogridmin", _col(tile), _col(resolution))
627617

628618

629619
def rst_h3_rastertogridmedian(tile: ColLike, resolution: ColLike) -> Column:
@@ -698,9 +688,7 @@ def rst_convolve(tile: ColLike, kernel: ColLike) -> Column:
698688
return f.call_function("gbx_rst_convolve", _col(tile), _col(kernel))
699689

700690

701-
def rst_derivedband(
702-
tile_expr: ColLike, pyfunc: ColLike, func_name: ColLike
703-
) -> Column:
691+
def rst_derivedband(tile_expr: ColLike, pyfunc: ColLike, func_name: ColLike) -> Column:
704692
"""Apply a Python UDF to each pixel (or band) to produce a derived band.
705693
706694
Args:
@@ -792,14 +780,10 @@ def rst_ndvi(tile: ColLike, red_band: ColLike, nir_band: ColLike) -> Column:
792780
Returns:
793781
Column of raster tile (single-band NDVI).
794782
"""
795-
return f.call_function(
796-
"gbx_rst_ndvi", _col(tile), _col(red_band), _col(nir_band)
797-
)
783+
return f.call_function("gbx_rst_ndvi", _col(tile), _col(red_band), _col(nir_band))
798784

799785

800-
def rst_rastertoworldcoord(
801-
tile: ColLike, pixel_x: ColLike, pixel_y: ColLike
802-
) -> Column:
786+
def rst_rastertoworldcoord(tile: ColLike, pixel_x: ColLike, pixel_y: ColLike) -> Column:
803787
"""Convert pixel (x, y) to world (x, y) in the CRS of the raster.
804788
805789
Args:
@@ -889,9 +873,7 @@ def rst_updatetype(tile: ColLike, new_type: ColLike) -> Column:
889873
return f.call_function("gbx_rst_updatetype", _col(tile), _col(new_type))
890874

891875

892-
def rst_worldtorastercoord(
893-
tile: ColLike, world_x: ColLike, world_y: ColLike
894-
) -> Column:
876+
def rst_worldtorastercoord(tile: ColLike, world_x: ColLike, world_y: ColLike) -> Column:
895877
"""Convert world (x, y) to pixel (x, y) in the raster.
896878
897879
Args:

python/geobrix/test/gridx/test_bng_functions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,12 @@ def test_bng_scalar_literal_args(spark, bng_registered):
640640
"""
641641
polygon_wkt = "POLYGON ((530000 180000, 530500 180000, 530500 180500, 530000 180500, 530000 180000))"
642642
df = spark.range(1).select(
643-
bng_registered.bng_pointascell(f.lit("POINT (400000 400000)"), 1).alias("cell_int_res"),
644-
bng_registered.bng_pointascell(f.lit("POINT (400000 400000)"), f.lit("1km")).alias(
645-
"cell_str_res"
643+
bng_registered.bng_pointascell(f.lit("POINT (400000 400000)"), 1).alias(
644+
"cell_int_res"
646645
),
646+
bng_registered.bng_pointascell(
647+
f.lit("POINT (400000 400000)"), f.lit("1km")
648+
).alias("cell_str_res"),
647649
bng_registered.bng_polyfill(f.lit(polygon_wkt), 1).alias("cells_int_res"),
648650
bng_registered.bng_kloop(f.lit("TQ388791"), 1).alias("kloop_int_k"),
649651
)

python/geobrix/test/sample/test_sample_bundle.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414

1515
import pytest
1616

17-
# Public API from package
17+
# Public API + the _bundle module itself (needed for internal-helper coverage tests below).
18+
from databricks.labs.gbx.sample import _bundle as _bundle_mod
1819
from databricks.labs.gbx.sample import (
1920
get_temp_dir,
2021
get_volumes_path,
2122
run_complete_bundle,
2223
run_essential_bundle,
2324
)
24-
# Internal helpers for coverage
25-
from databricks.labs.gbx.sample import _bundle as _bundle_mod
26-
2725

2826
# ========== __init__ (package surface) ==========
2927

0 commit comments

Comments
 (0)