Style: fix flake8/isort findings in cost_distance.py (#3339)#3350
Merged
Conversation
Categories addressed: - Cat 3 (F401): remove unused `from functools import partial` (refactor leftover; not re-exported) - Cat 5 (mutable default): public `cost_distance(target_values=[])` -> `None` sentinel normalized to `[]` in the body, mirroring proximity.py (#2725). Reassigned via np.asarray before any mutation, so behaviour is preserved. Adds regression tests covering default reuse and None. - Cat 1 (E302): two blank lines before `@ngjit _heap_push` - Cat 1 (E127): fix continuation-line over-indent in _cost_distance_dask_cupy and _cost_distance_dask_iterative signatures - Cat 4 (isort): dataset_support before utils; utils from-import reflowed to 100 cols No behavioural change for the Cat 1/3/4 fixes. The Cat 5 change preserves behaviour. flake8 and isort --check-only are clean on the module; 57 cost_distance tests pass.
…_distance-2026-06-15
…_distance-2026-06-15 # Conflicts: # xrspatial/tests/test_cost_distance.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3339
Style cleanup of
xrspatial/cost_distance.pyagainst the project's flake8 (max-line-length=100) and isort (line_length=100) config.Changes
from functools import partial(unused refactor leftover, not re-exported).cost_distance()signature usedtarget_values: list = []. Switched to aNonesentinel normalized to[]in the body, matching howproximity.pywas fixed in Style cleanup in xrspatial/proximity.py (flake8 F841/E128, isort, mutable default) #2725. The argument is reassigned vianp.asarraybefore anything mutates it, so the shared list never actually leaked, but the pattern is now correct. Added two regression tests: one confirms the default produces identical results across calls, the other confirmstarget_values=Nonematches the empty default.@ngjit _heap_pushdefinition._cost_distance_dask_cupyand_cost_distance_dask_iterativesignatures.xrspatial.dataset_supportsorts beforexrspatial.utils; the utils from-import reflows to 100 columns.No behavioural change is intended for the Cat 1/3/4 fixes. The Cat 5 change preserves behaviour.
Backends
Style-only change, applies uniformly across numpy / cupy / dask+numpy / dask+cupy. The mutable-default fix is in the shared public entry point.
Test plan
xrspatial/cost_distance.pyxrspatial/cost_distance.pyPre-existing lint in
test_cost_distance.py(F401, E201, isort drift) was left untouched as out of scope for this module sweep.