aspect: planar dask backends report float32 dtype matching computed data#2741
Merged
Conversation
The planar dask backends called map_overlap with a default-dtype meta (np.array(()) / cupy.array(())), so the lazy DataArray advertised float64 while the chunk functions return float32. numpy and cupy backends already report float32. Pass an explicit float32 dtype to the meta so the advertised dtype matches the computed data across all four backends. The geodesic dask paths already set dtype=np.float32; only the planar paths were affected.
brendancol
commented
May 30, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
PR Review: aspect planar dask backends report float32 dtype matching computed data
Blockers (must fix before merge)
None.
Suggestions (should fix, not blocking)
None. One optional coverage gap below.
Nits (optional improvements)
- The two new tests only cover the default
boundary='nan'path. The
other boundary modes run through_pad_arrayand then hit the same
chunk functions, so they return float32 too, but a parametrize over
boundary would pin that down. Low value, skip if you prefer.
What looks good
- The fix is minimal and correct.
_cpu/_run_cupyalready cast to
float32 and return it, so declaring float32 in the meta is the right
call, and it matches what the geodesic dask paths in this same file
already do. - numpy and cupy already reported float32. This brings the two planar
dask paths in line, so all four backends now agree on both the lazy
and the computed dtype. - Both dask paths get the same treatment.
- The tests check both the lazy advertised dtype and the dtype after
compute, which is the actual bug in #2682: the two disagreed. - The computation itself is untouched. No change to NaN handling, depth,
or boundary forwarding.
Checklist
- Algorithm: unchanged, dtype-only fix
- Backend consistency: float32 verified on numpy, cupy, dask+numpy, dask+cupy
- NaN handling: unchanged
- Edge cases: dtype consistency covered; boundary-mode dtype not parametrized (low risk)
- Dask chunk boundaries: unchanged, depth=(1,1)
- No premature materialization or copies: confirmed
- Benchmark: not needed, no perf change
- README feature matrix: not applicable, no API change
- Docstrings: unchanged
brendancol
commented
May 30, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after 7c9017a)
The one nit from the previous pass is addressed: test_dask_numpy_advertised_dtype_matches_computed is now parametrized over all four boundary modes (nan, nearest, reflect, wrap), so the _pad_array path is covered for dtype too. All five dtype tests pass.
No new findings. Nothing blocking.
This was referenced May 31, 2026
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 #2682
What this fixes
The planar dask backends of
aspect()advertised a lazy dtype offloat64, but the array they actually computed wasfloat32. The numpyand cupy backends already reported
float32, so the dtype you sawdepended on which backend was active, and it silently changed from
float64tofloat32once.compute()ran.Root cause:
_run_dask_numpyand_run_dask_cupycalledmap_overlapwith a default-dtype meta (
np.array(())/cupy.array(())), whichdefaults to float64. The chunk functions
_cpu/_run_cupyreturnfloat32. The fix passes an explicit float32 dtype to the meta, matching
what the geodesic dask paths already do.
northness()andeastness()derive fromaspect(), so they inheritthe corrected dtype.
Backend coverage
Test plan
test_dask_numpy_advertised_dtype_matches_computedasserts lazyand computed dtype are both float32
test_dask_cupy_advertised_dtype_matches_computedcovers theGPU dask path
test_aspect.pysuite passes (66 passed, cupy + dask+cupyincluded on a CUDA host)
Note
slope.pyandcurvature.pyuse the same default-dtype meta pattern ontheir planar dask paths and likely have the same inconsistency. Out of
scope for this PR (metadata sweep was scoped to aspect).