Skip to content

Fix float32 dtype leak in flood_depth/curve_number_runoff dask backends#3509

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-accuracy-flood-2026-06-25
Jun 26, 2026
Merged

Fix float32 dtype leak in flood_depth/curve_number_runoff dask backends#3509
brendancol merged 2 commits into
mainfrom
deep-sweep-accuracy-flood-2026-06-25

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3499

flood_depth and curve_number_runoff document a float64 output. The numpy and cupy helpers cast the input to float64, but _flood_depth_dask and _cn_runoff_dask operated on the input array with no cast, so a float32 input returned float32 on the dask and dask+cupy backends.

Change

  • Cast hand to float64 at the top of _flood_depth_dask.
  • Cast p to float64 at the top of _cn_runoff_dask.

The dask+cupy wrappers reuse the dask helpers, so all four backends now return float64. The other flood functions already returned float64 on every backend (the float64 _TAN_MIN clamp, the 1.0/0.0 literals in inundation, and np.interp in vegetation_roughness).

Backend coverage

numpy, cupy, dask+numpy, dask+cupy. Added 8 dtype tests (one per function per backend) that feed a float32 input and assert a float64 result. Verified locally on a CUDA host (96 flood tests pass).

Test plan

  • pytest xrspatial/tests/test_flood.py (96 passed, includes cupy and dask+cupy)
  • Confirmed the new tests fail on the pre-fix dask path (float32) and pass after the cast

…ds (#3499)

numpy and cupy cast the input to float64, but _flood_depth_dask and
_cn_runoff_dask operated on the input array without a cast, so a float32
input returned float32 on the dask and dask+cupy backends. Both functions
document a float64 output. Cast hand/p to float64 at the top of the dask
helpers so all four backends agree.

Adds float32-input dtype tests across numpy, dask, cupy, and dask+cupy.
Updates the sweep-accuracy state CSV.

Closes #3499
…lood-2026-06-25

# Conflicts:
#	xrspatial/flood.py
#	xrspatial/tests/test_flood.py
@brendancol brendancol merged commit e862f04 into main Jun 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flood_depth and curve_number_runoff return float32 on dask backends for float32 input

1 participant