From 0fb01f5d66425c797476e320bab5156334a203e2 Mon Sep 17 00:00:00 2001 From: Brendan Collins Date: Fri, 12 Jun 2026 09:41:19 -0700 Subject: [PATCH] Drop unused math import and fix isort drift in interpolate (#3286) --- .claude/sweep-style-state.csv | 1 + xrspatial/interpolate/_idw.py | 11 ++--------- xrspatial/interpolate/_spline.py | 9 ++------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.claude/sweep-style-state.csv b/.claude/sweep-style-state.csv index 0435e0870..1ed258dcb 100644 --- a/.claude/sweep-style-state.csv +++ b/.claude/sweep-style-state.csv @@ -4,6 +4,7 @@ contour,2026-05-29,2698,HIGH,3,"F821 line 557: contours() return annotation ""gp focal,2026-05-29,2731,HIGH,3;4;5,"F401 not_implemented_func (import line 36, unused, not re-exported). isort: stdlib reorder (import math before from-imports), dropped stray blank lines in import groups, alphabetised+rewrapped convolution/utils from-imports, moved dataset_support import into order. Cat 5: mutable default excludes=[np.nan] in mean() (line 238) -> None sentinel, resolved to [np.nan] in body; never mutated so behaviour preserved; regression test test_mean_default_excludes_does_not_leak added. Cat 1/2 clean. 115 focal tests pass. PR pending." geotiff,2026-06-12,3259,MEDIUM,4,"Re-sweep after #3082: flake8 baseline 0 across whole subpackage incl tests. Cat 4 only: isort drift in _writers/gpu.py (the from .._attrs import block wrapped at ~80 cols instead of configured 100); rewrapped. Cat 1/2/3/5 clean: no E/W/F codes, no bare except or mutable defaults; type=/id= grep hits are getaddrinfo/pytest.param kwargs and ': list'/': dict' annotation hits, not shadowed builtins. 734 write+gpu tests pass (CUDA available). PR via #3259." hydro-d8,2026-05-29,2705,HIGH,1;3;4,"flake8+isort over the 13 D8 files only (dinf/mfd out of scope). Cat 3 HIGH: F401 x2 (flow_length_d8 function-local _compute_accum_seeds never called; snap_pour_point_d8 module-level cuda_args unused) - both confirmed dead, no re-export. Cat 1: E127/E128 continuation-indent x90 (mostly multi-line def signatures); E302/E303 blank-line cluster in watershed_d8; E501 x4 (flow_path_d8 + snap_pour_point_d8, wrapped ternaries). Cat 4: isort import-block reordering on all 13 files. No Cat 2 (W-codes), no Cat 5 (grep clean: no bare except, mutable defaults, ==None/==True, or shadowed builtins). flake8+isort clean after fix; 385 D8 tests pass. flow_direction_d8 needed manual blank-line placement to satisfy both isort and E302." +interpolate,2026-06-12,3286,HIGH,3;4,"Full subpackage sweep (_idw, _kriging, _spline, _validation). Cat 3 F401: unused 'import math' in _idw.py L5 (IDW kernels are pure arithmetic; _spline.py keeps math for math.log in TPS kernels; not re-exported, __init__ exports only idw/kriging/spline). Cat 4 isort: _idw.py + _spline.py 5-line xrspatial.utils from-import reflowed to 2 lines under line_length=100, matching _kriging.py from #2916. Cat 1/2/5 clean (no E/W codes; grep: no bare except, mutable defaults, ==None/True, shadowed builtins). flake8+isort clean after fix; 66 interpolation tests pass (CUDA available). PR open." interpolate-kriging,2026-06-04,2916,MEDIUM,1;4,"flake8 E128 x2: continuation-line under-indent at the _chunk_var kriging-predict calls in _kriging_dask_numpy (L234) and _kriging_dask_cupy (L324); re-indented to visual-indent column. Cat 4 isort: 5-line from xrspatial.utils (...) block collapses to one 88-char line under line_length=100. Cat 2/3/5 grep clean (no W-codes, F-codes, bare except, mutable defaults, ==None/True, or shadowed builtins). flake8+isort clean after fix; 14 kriging tests pass. PR open." mcda,2026-06-10,3143,HIGH,3;4,F401 dead function-local warnings import in standardize.py; isort drift in weights.py combine.py __init__.py; flake8 otherwise clean; Cat 5 greps clean; fixed via PR for #3143 polygon_clip,2026-06-10,3184,HIGH,3;4,"Cat 3 F401: dropped unused typing imports Sequence/Tuple/Union (line 10, only Optional used) and the dead 'import cupy' inside the _apply_mask dask+cupy closure (line 245); the other 'import cupy' at line 261 is used (cupy.asarray) and kept. None re-exported (__init__ re-exports only clip_polygon). Cat 4 isort: reflowed the 5-name xrspatial.utils from-import block to line_length=100. Cat 1/2/5 grep clean (no E/W codes, no bare except, mutable defaults, ==None/True, or shadowed builtins). flake8+isort clean after fix; 23 test_polygon_clip tests pass. PR open." diff --git a/xrspatial/interpolate/_idw.py b/xrspatial/interpolate/_idw.py index de9aece4b..bff64243a 100644 --- a/xrspatial/interpolate/_idw.py +++ b/xrspatial/interpolate/_idw.py @@ -2,19 +2,12 @@ from __future__ import annotations -import math - import numpy as np import xarray as xr from numba import cuda -from xrspatial.utils import ( - ArrayTypeFunctionMapping, - _validate_raster, - _validate_scalar, - cuda_args, - ngjit, -) +from xrspatial.utils import (ArrayTypeFunctionMapping, _validate_raster, _validate_scalar, + cuda_args, ngjit) from ._validation import extract_grid_coords, validate_points diff --git a/xrspatial/interpolate/_spline.py b/xrspatial/interpolate/_spline.py index f74e9fc11..e1c62b589 100644 --- a/xrspatial/interpolate/_spline.py +++ b/xrspatial/interpolate/_spline.py @@ -8,13 +8,8 @@ import xarray as xr from numba import cuda -from xrspatial.utils import ( - ArrayTypeFunctionMapping, - _validate_raster, - _validate_scalar, - cuda_args, - ngjit, -) +from xrspatial.utils import (ArrayTypeFunctionMapping, _validate_raster, _validate_scalar, + cuda_args, ngjit) from ._validation import extract_grid_coords, validate_points