Fix hypsometric_integral dask+cupy backend (#2525)#2529
Merged
Conversation
_hi_dask_cupy converted cupy chunks to numpy then delegated to _hi_dask_numpy, returning a dask+numpy array even when the input was dask+cupy. Wrap the painted output through map_blocks(cupy.asarray, ...) so chunks land back as cupy arrays. is_dask_cupy(result) is now True for dask+cupy inputs, matching _regions_dask_cupy's behavior. Add test_hi_preserves_backend_2525 covering all four backends (numpy / cupy / dask+numpy / dask+cupy). Closes #2525
Replace locally redeclared _has_cuda_and_cupy with has_cuda_and_cupy from xrspatial.utils, and use has_dask_array() instead of `da is None`. Same pattern other tests follow. Drop the em-dash in the _hi_dask_cupy docstring while in the area.
Contributor
Author
Review summaryThe fix is correct and minimal. BlockersNone. SuggestionsNone blocking. The extra Nits applied in follow-up commit
What looks good
Pre-existing items (not from this PR)
|
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 #2525.
Summary
_hi_dask_cupypreviously converted cupy chunks to numpy and then called_hi_dask_numpy, returning a dask+numpy result for dask+cupy input. DownstreamArrayTypeFunctionMappingdispatch silently routed through the numpy path.map_blocks(cupy.asarray, ...)so each chunk lands back as a cupy array. The dask graph stays lazy andis_dask_cupy(result)is True for dask+cupy inputs.Backend coverage
Test plan
test_hi_preserves_backend_2525asserts the output backend matches the input across all four backends.test_hypsometric_integral.pysuite still passes (33 tests).test_zonal.pysuite still passes (125 tests).Audit trail
Surfaced by
/sweep-metadataon the zonal module, 2026-05-27. Cat 5 (backend-inconsistent metadata), severity MEDIUM.