Skip to content

Propagate NaN from curve_number in curve_number_runoff (#1104)#1105

Merged
brendancol merged 1 commit into
masterfrom
issue-1104
Mar 31, 2026
Merged

Propagate NaN from curve_number in curve_number_runoff (#1104)#1105
brendancol merged 1 commit into
masterfrom
issue-1104

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Fixes #1104. curve_number_runoff returned 0 instead of NaN when the curve_number raster had NaN cells. The NaN fixup only checked np.isnan(p) (rainfall), missing np.isnan(cn). When CN is NaN, P > NaN is always False, so np.where took the else-branch and wrote 0.0.

Fixed in all three backend functions (_cn_runoff_numpy, _cn_runoff_cupy, _cn_runoff_dask) to check both p and cn for NaN.

Test plan

  • test_cn_runoff_nan_curve_number_1104: NaN curve number produces NaN, valid CN produces valid runoff
  • Full test_flood.py suite: 82 passed

The NaN fixup only checked np.isnan(p), missing NaN in the curve
number raster. When CN is NaN, P > NaN is False, so np.where wrote
0.0 instead of NaN. Now checks both p and cn in all three backends.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 31, 2026
@brendancol brendancol merged commit 0d4bb18 into master Mar 31, 2026
11 checks passed
@brendancol brendancol deleted the issue-1104 branch May 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

curve_number_runoff returns 0 instead of NaN for NaN curve numbers

1 participant