Skip to content

test(classify): cover all-NaN degenerate input across classifiers#3515

Merged
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-test-coverage-classify-2026-06-25-01
Jun 26, 2026
Merged

test(classify): cover all-NaN degenerate input across classifiers#3515
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-test-coverage-classify-2026-06-25-01

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Adds all-NaN regression tests for the classifiers that lacked them.

std_mean and maximum_breaks already return an all-NaN result on
all-NaN input, so they get plain passing tests. head_tail_breaks,
percentiles, and box_plot currently crash on all-NaN input, so their
tests are xfail (non-strict) and reference the source bug in #3510. Flip
them to plain assertions once #3510 is fixed.

equal_interval and natural_breaks already had all-NaN coverage.

Test-only change, no source modified. Ran locally on a CUDA host:
4 passed, 3 xfailed.

Found by the test-coverage sweep. Fixes the coverage half of #3510.

Adds all-NaN regression tests for the classifiers that lacked them.
std_mean and maximum_breaks already return an all-NaN result and get
plain passing tests. head_tail_breaks, percentiles, and box_plot crash
on all-NaN input (issue xarray-contrib#3510); their tests are xfail (non-strict) until
that is fixed.

Test-only change, no source modified.
Addresses review on PR xarray-contrib#3515. The all-NaN degenerate path diverges by
backend, so the numpy-only tests missed cases:
- std_mean, maximum_breaks: all-NaN on numpy and dask -> passing dask tests
- head_tail_breaks: crashes eager but the dask path has a total_count == 0
  guard and returns all-NaN -> plain passing dask test (documents xarray-contrib#3510 is
  eager-only)
- percentiles, box_plot: crash on dask too -> xfail(xarray-contrib#3510) dask tests

Also wraps the std_mean all-NaN tests in warnings.catch_warnings() to drop
the empty-slice RuntimeWarnings.

Test-only, no source modified.
@brendancol

Copy link
Copy Markdown
Contributor Author

Review: degenerate-input regression tests for classify

Blockers: none.

Suggestion (addressed in a8cbf28): the all-NaN tests ran on numpy only, but the degenerate path diverges by backend. Running all five on dask:

  • std_mean and maximum_breaks return all-NaN on both eager and dask
  • head_tail_breaks crashes eager, but its dask path returns all-NaN cleanly because of a total_count == 0 guard the eager path lacks
  • percentiles and box_plot crash on dask too

Added five @dask_array_available all-NaN tests: passing for std_mean, maximum_breaks, and head_tail_breaks (dask); xfail(#3510) for percentiles and box_plot (dask). Also wrapped the std_mean all-NaN tests in warnings.catch_warnings() to drop three empty-slice RuntimeWarnings.

Note for #3510: the head_tail_breaks crash is eager-only (numpy/cupy). The source fix should bring the eager paths in line with the existing dask guard.

What looks good: xfail(strict=False) is the right call with parallel sweeps in flight, since the tests assert the real all-NaN result and the xfails flip to pass exactly when #3510 lands. Full test_classify.py: 107 passed, 5 xfailed.

@brendancol brendancol merged commit b7d50fb into xarray-contrib: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.

1 participant