Fix flood dask backends emitting float32 output for float32 input#3498
Merged
Conversation
flood_depth() and curve_number_runoff() document a float64 output and force float64 on the numpy/cupy backends. The dask and dask+cupy backends ran directly on the input dtype, so a float32 input produced a float32 result and the output dtype depended on the active backend. Cast the input to float64 in _flood_depth_dask and _cn_runoff_dask to match the numpy/cupy backends and the documented contract. Adds float32 input dtype tests across all four backends. Fixes #3496
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.
Summary
flood_depth()andcurve_number_runoff()document a "2D float64 grid" return value. The numpy and cupy backends force float64; the dask and dask+cupy backends ran directly on the input array's dtype, so a float32 input produced a float32 result. The output dtype depended on which backend was active.Fix
Cast the input to float64 in
_flood_depth_daskand_cn_runoff_dask, matching the numpy/cupy backends and the documented contract.travel_time()andflood_depth_vegetation()were already float64 on every backend (their_TAN_MINclamp is annp.float64scalar that forces promotion) and are untouched.Tests
Adds float32-input dtype tests for both functions across numpy, cupy, dask, and dask+cupy. Full flood suite passes locally (97 tests, GPU paths included).
Fixes #3496
Found by the metadata-propagation sweep.