Compute dask source once in cumulative_viewshed (#3185)#3199
Merged
Conversation
cumulative_viewshed called viewshed() per observer; on the dask no-max_distance path each call computed the same source raster, so the source was materialised once per observer. Compute it once up front when every observer takes the full-grid path, run the observers against the in-memory raster, then re-wrap the count as dask to preserve the output backend. Observers that set max_distance keep the dask windowing path. Adds tests asserting the source is computed once and that the per-observer max_distance path stays lazy with dask/numpy parity.
Contributor
Author
PR Review: Compute dask source once in cumulative_viewshed(Posted as a comment via REST; BlockersNone. Suggestions
Nits
What looks good
Checklist
|
…e-visibility-2026-06-10
Conflicts: - .claude/sweep-performance-state.csv: main normalized the file to LF and updated the rasterize row; this branch updated the visibility row. Took main's LF file and reapplied the branch's visibility row. xrspatial/visibility.py auto-merged (main side was the isort-only #3189).
# Conflicts: # xrspatial/tests/test_visibility.py # xrspatial/visibility.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 #3185
What changed
cumulative_viewshedcalledviewshed()once per observer. On the dask path with nomax_distance, every call ranraster.data.compute()on the same source, so the source was materialised once per observer.max_distance), the source is now computed once up front and the observers run against the in-memory raster. The accumulated count is re-wrapped as dask so the output backend still matches the dask input.max_distancekeep the dask windowing path, which loads only each observer's window.Backend coverage
max_distancepath; per-observermax_distancebehaviour unchanged.Test plan
test_dask_source_computed_onceasserts a single source compute for four observers and a dask-backed output.test_dask_per_observer_max_distance_stays_lazyasserts the windowed path stays dask and matches numpy.test_dask_matches_numpyparity check still passes.test_visibility.pysuite: 27 passed.