diff --git a/.claude/sweep-style-state.csv b/.claude/sweep-style-state.csv index 598c4de92..bff5f4ab1 100644 --- a/.claude/sweep-style-state.csv +++ b/.claude/sweep-style-state.csv @@ -11,6 +11,7 @@ hydro-d8,2026-05-29,2705,HIGH,1;3;4,"flake8+isort over the 13 D8 files only (din 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 +morphology,2026-06-20,3400,HIGH,3;4,"F401 xr/has_cuda_and_cupy/not_implemented_func + F841 size (dead); isort ordering. /rockout PR off issue 3400. flake8+isort clean, 74 tests pass." 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." polygonize,2026-05-27,2534,HIGH,1;3;4,"F401 line 58 (is_cupy_array unused, not re-exported). E127 lines 83/88 (overload continuation indent in generated_jit). isort: 5-line .utils import block collapses to one line at 100-char limit. Cat 2 clean. Cat 5 grep clean." proximity,2026-06-18,,MEDIUM,4,"Re-audit 2026-06-18 (file last modified 2026-06-14). Cat 4 isort: from xrspatial.utils import (...) block wrapped one name early for line_length=100; pulled has_cuda_and_cupy onto first continuation line (both lines <=100, flake8 clean). isort+flake8 now clean. Fix applied + verified imports resolve. Cat 1/2/3 clean. Cat 5 grep: target_values: list = None on L1540/1700/1859 are type annotations not builtin-shadowing vars (false positive); mutable-default already None-sentinel from prior #2725. MEDIUM. /rockout issue+PR creation BLOCKED by auto-mode classifier (external publish denied); fix committed to deep-sweep branch only." diff --git a/xrspatial/morphology.py b/xrspatial/morphology.py index d183b11c1..5bb80e3e5 100644 --- a/xrspatial/morphology.py +++ b/xrspatial/morphology.py @@ -16,10 +16,8 @@ from functools import partial import numpy as np -import xarray as xr -from xarray import DataArray - from numba import cuda, prange +from xarray import DataArray try: import cupy @@ -32,26 +30,16 @@ class cupy: except ImportError: da = None -from xrspatial.utils import ( - ArrayTypeFunctionMapping, - _boundary_to_dask, - _dask_task_name_kwargs, - _pad_array, - _validate_boundary, - _validate_raster, - calc_cuda_dims, - has_cuda_and_cupy, - has_dask_array, - ngjit, - not_implemented_func, -) from xrspatial.dataset_support import supports_dataset - +from xrspatial.utils import (ArrayTypeFunctionMapping, _boundary_to_dask, _dask_task_name_kwargs, + _pad_array, _validate_boundary, _validate_raster, calc_cuda_dims, + has_dask_array, ngjit) # --------------------------------------------------------------------------- # Memory guard # --------------------------------------------------------------------------- + def _available_memory_bytes(): """Best-effort estimate of available memory in bytes.""" # Try /proc/meminfo (Linux) @@ -104,7 +92,6 @@ def _circle_kernel(radius): The kernel has shape ``(2*radius+1, 2*radius+1)`` with ``True`` for cells whose centre is within *radius* cells of the centre. """ - size = 2 * radius + 1 y, x = np.ogrid[-radius:radius + 1, -radius:radius + 1] return (x * x + y * y <= radius * radius).astype(np.uint8)