Skip to content

aspect: fix flake8 E402/E305/E501 in aspect.py#2740

Open
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-style-aspect-2026-05-29
Open

aspect: fix flake8 E402/E305/E501 in aspect.py#2740
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-style-aspect-2026-05-29

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2683

What

  • Moved the from xrspatial.geodesic import (...) block from below _geodesic_cuda_dims up to the other top-of-file imports. Fixes E402 (import not at top) and E305 (blank lines after function def).
  • Wrapped two over-long _run_gpu_geodesic_aspect[griddim, blockdim](...) kernel-launch calls. Fixes both E501 (101 and 109 chars).

flake8 xrspatial/aspect.py now reports zero violations.

Categories addressed

Cat 1 (flake8 E-codes: E402, E305, E501).

Cat 4 (isort) was reviewed and intentionally not applied: slope.py and curvature.py use one-import-per-line for xrspatial.utils, and isort --check-only flags them the same way. Applying the raw isort diff would collapse aspect's imports and make it inconsistent with its sibling terrain modules. No config widening, no # noqa.

Cat 2, Cat 3, and Cat 5 (bare except / mutable defaults / == None / shadowed builtins) were grepped and are clean.

No behavioural change

Static reformatting only. All four backends (numpy / cupy / dask+numpy / dask+cupy) share the same source, so no backend-specific verification is needed.

Test plan

  • flake8 xrspatial/aspect.py clean
  • pytest xrspatial/tests/test_aspect.py (64 passed)
  • pytest xrspatial/tests/test_geodesic_aspect.py (18 passed)
  • Import + smoke test of aspect / northness / eastness

Move the xrspatial.geodesic import up with the other top-of-file
imports (it sat below _geodesic_cuda_dims, triggering E402 + E305).
Wrap two over-long _run_gpu_geodesic_aspect kernel-launch calls (E501).

Style only, no behavioural change. isort reordering intentionally not
applied: slope.py/curvature.py use one-import-per-line for
xrspatial.utils, and raw isort would make aspect inconsistent with them.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 30, 2026
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: aspect: fix flake8 E402/E305/E501 in aspect.py

Blockers

None.

Suggestions

None.

Nits

None.

What looks good

  • The diff is exactly the three intended changes and nothing else. No adjacent code touched.
  • Relocating the xrspatial.geodesic import to the top is semantically identical. The module imports cleanly with no dependency on _geodesic_cuda_dims, confirmed by the passing test run. This also resolves the real readability problem of an import hidden below a function def.
  • Both line-wraps are whitespace-only inside the argument lists of the _run_gpu_geodesic_aspect[...] kernel launches. No behavioural change.
  • The decision to skip the isort reordering is correct: slope.py and curvature.py use one-import-per-line for xrspatial.utils, so applying the raw isort diff would make aspect the odd one out. Documented in the PR body rather than silently suppressed.

Checklist

  • Algorithm matches reference/paper (no algorithm change)
  • All implemented backends produce consistent results (static reformat; shared source)
  • NaN handling is correct (untouched)
  • Edge cases are covered by tests (existing suite exercises every changed line)
  • Dask chunk boundaries handled correctly (untouched)
  • No premature materialization or unnecessary copies (no compute change)
  • Benchmark exists or is not needed (not needed for a style fix)
  • README feature matrix updated (not applicable)
  • Docstrings present and accurate (untouched)

Verified locally: flake8 xrspatial/aspect.py clean; pytest test_aspect.py 64 passed; pytest test_geodesic_aspect.py 18 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspect.py: flake8 E402/E305/E501 violations from a misplaced import block

1 participant