proximity: fix bounded GREAT_CIRCLE crash on dask backends#2722
Open
brendancol wants to merge 2 commits into
Open
proximity: fix bounded GREAT_CIRCLE crash on dask backends#2722brendancol wants to merge 2 commits into
brendancol wants to merge 2 commits into
Conversation
The dask map_overlap pad depth was computed as max_distance / cellsize, but cellsize is in degrees while max_distance is in metres for the GREAT_CIRCLE metric. The resulting depth (hundreds of thousands of pixels) made dask raise ValueError on valid input that the numpy and cupy backends handle fine. Measure the per-pixel pitch with the active distance metric instead of the raw degree cellsize, so the overlap depth is in pixels for all metrics. EUCLIDEAN and MANHATTAN are unaffected (max_distance shares units with the cellsize). Adds a regression test covering proximity/allocation/direction.
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.
Fixes #2721
Problem
Calling
proximity/allocation/directionwithdistance_metric='GREAT_CIRCLE'and a finitemax_distanceraisesValueError: The overlapping depth N is larger than your arrayon dask-backed rasters (both dask+numpy and dask+cupy). The numpy and cupy backends accept the same call and return correct results.The
map_overlapoverlap depth was computed asmax_distance / cellsize. The cellsize is in degrees, butmax_distancefor GREAT_CIRCLE is in metres, so the depth came out to hundreds of thousands of pixels.Fix
Measure the per-pixel pitch with the active distance metric (great-circle metres between adjacent cells) rather than the raw degree cellsize, so the overlap depth is in pixels for every metric. Applied to both the dask+numpy path (
_process_dask) and the dask+cupy path (_process_dask_cupy). EUCLIDEAN and MANHATTAN are unaffected because theirmax_distancealready shares units with the cellsize. The now-unusedget_dataarray_resolutionimport is dropped.Tests
Added
test_great_circle_dask_bounded_matches_numpy, parametrized over proximity/allocation/direction, asserting the dask result matches the numpy result. It fails withValueErroron the old code and passes after the fix. Fulltest_proximity.pysuite passes on all four backends (numpy, dask+numpy, cupy, dask+cupy).Found via an accuracy sweep (Cat 4 projection/unit handling, Cat 5 backend parity).