Skip to content

Add tests for all-NaN auto-levels RuntimeWarning regression (#2795)#3009

Open
Melissari1997 wants to merge 2 commits into
xarray-contrib:mainfrom
Melissari1997:issue-2795
Open

Add tests for all-NaN auto-levels RuntimeWarning regression (#2795)#3009
Melissari1997 wants to merge 2 commits into
xarray-contrib:mainfrom
Melissari1997:issue-2795

Conversation

@Melissari1997
Copy link
Copy Markdown
Contributor

Closes #2795.

  • Add test coverage for contours() on all-NaN rasters with auto level selection, verifying no RuntimeWarning is emitted.
  • Tests cover numpy, dask+numpy, cupy, and dask+cupy backends.

The warning suppression was already in place (commit 58a44c3), but lacked explicit test coverage to prevent regression.

Backend coverage:

  • numpy: tested
  • dask+numpy: tested
  • cupy: tested (skipped when cupy unavailable)
  • dask+cupy: tested (skipped when cupy unavailable)

Test checklist:

  • All-NaN numpy raster with auto levels returns empty, no RuntimeWarning
  • All-NaN dask raster with auto levels returns empty, no RuntimeWarning
  • All-NaN cupy/dask+cupy tests included (skipped without GPU)
  • Existing contour tests still pass

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 7, 2026
Copy link
Copy Markdown
Contributor Author

@Melissari1997 Melissari1997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add tests for all-NaN auto-levels RuntimeWarning regression (#2795)

Summary

Test-only PR adding regression coverage for contours() on all-NaN rasters with auto level selection. The warning suppression was already implemented in commit 58a44c3; this PR ensures it does not regress.

Findings

No Blockers.

Suggestions:

  • None.

Nits:

  • The import warnings is repeated inside each test method. Consider moving it to the module-level imports at the top of the file to avoid redundancy across the four new tests.

Assessment

  • Test structure follows existing patterns in TestNaNHandling
  • Backend coverage is complete (numpy, dask+numpy, cupy, dask+cupy)
  • All tests pass in the local environment
  • PR correctly targets the upstream repo

Copy link
Copy Markdown
Contributor Author

@Melissari1997 Melissari1997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review: Address review nit (#2795)

Moved import warnings to module-level imports. All four new tests now share the single module-level import. No functional changes.

Assessment

  • Nit addressed
  • Tests still pass
  • Ready for merge

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.

contours() emits RuntimeWarning on all-NaN input with auto level selection

1 participant