Style cleanup in viewshed.py: rename shadowed id, fix E127 + isort#2695
Open
brendancol wants to merge 2 commits into
Open
Style cleanup in viewshed.py: rename shadowed id, fix E127 + isort#2695brendancol wants to merge 2 commits into
brendancol wants to merge 2 commits into
Conversation
…array-contrib#2690) - Rename local id -> node_id at the two _insert_into_tree call sites (L1409, L1474) so it no longer shadows the id builtin. The value maps to the node_id parameter in _insert_into_tree. Pure local rename, no behavioural change. - Fix E127 over-indented continuation lines in the _viewshed_distance_sweep signature. - Reflow the .utils import block to satisfy isort line_length=100. Also record the viewshed row in .claude/sweep-style-state.csv. flake8 and isort both clean; 25 viewshed tests pass.
brendancol
commented
May 29, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
Review: style cleanup in viewshed.py
I read the full diff plus the surrounding code in _viewshed_cpu_sweep and _viewshed_distance_sweep, and re-ran the tooling against the head branch.
Blockers: none. Suggestions: none. Nits: none.
What looks good:
- The
idtonode_idrename is complete. No bareidtokens are left in the file, andnode_idis already the parameter name in_insert_into_tree(line 321) and_find_value_min_value(line 75), so the rename follows existing module naming rather than inventing something new. - No collision:
node_idwasn't a local in_viewshed_cpu_sweepbefore, so nothing gets clobbered. - The E127 fix lines the continuation up with the opening paren in the
_viewshed_distance_sweepsignature. flake8 reports zero now. - The isort change just rewraps the
.utilsblock; the imported names are identical. - Checked locally: flake8 exits 0,
isort --check-onlyexits 0. - Behavior is unchanged. The renamed locals sit inside numba-jitted code and a local rename doesn't affect codegen. The 25 tests in
test_viewshed.pypass and a numpy smoke test runs through both rename sites.
Checklist (most items not applicable for a static style change):
- Algorithm vs reference: n/a, no algorithm change
- Backend consistency: n/a, applies uniformly
- NaN handling: n/a, unchanged
- Edge-case tests: existing coverage unchanged and passing
- Dask chunk boundaries: n/a, unchanged
- Premature materialization: n/a, unchanged
- Benchmark: not needed
- README feature matrix: n/a, no API change
- Docstrings: unchanged
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 #2690.
Style-only cleanup of
xrspatial/viewshed.py. Limited to what flake8 (max-line-length=100) and isort (line_length=100) flag, plus one manual rename. No formatter was run and no config was widened.What changed:
idtonode_idat the two_insert_into_treecall sites (lines 1409 and 1474). It was shadowing theidbuiltin, and the value already maps to the callee'snode_idparameter, so the name now matches. Pure local rename._viewshed_distance_sweepsignature..utilsimport block for isort.This covers the style sweep's Cat 1 (E127), Cat 4 (isort), and Cat 5 (shadowed
idbuiltin). None of it changes runtime behavior; theidrename is just a local variable inside numba-jitted code, and the rest is formatting. Style fixes apply uniformly across the numpy/cupy/dask backends, so there's no per-backend verification to do.Test plan:
flake8 xrspatial/viewshed.pyreports nothingisort --check-only --diff xrspatial/viewshed.pyis cleanxrspatial/tests/test_viewshed.pypass_insert_into_treecall sites