Skip to content

Test mahalanobis Inf input, all-NaN, and degenerate shapes (#3583)#3584

Open
brendancol wants to merge 1 commit into
xarray-contrib:mainfrom
brendancol:deep-sweep-test-coverage-mahalanobis-2026-06-30
Open

Test mahalanobis Inf input, all-NaN, and degenerate shapes (#3583)#3584
brendancol wants to merge 1 commit into
xarray-contrib:mainfrom
brendancol:deep-sweep-test-coverage-mahalanobis-2026-06-30

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3583.

mahalanobis() already covers all four backends and NaN propagation. This adds tests for three paths that ran without any coverage. I probed each on a CUDA host first, so they all behave correctly today; this is regression-guarding, not a bug fix.

  • Inf / -Inf input (test_inf_*): a non-finite cell in any band becomes NaN in the output and is dropped from the auto-computed statistics. Asserted identical across numpy, cupy, dask+numpy, and dask+cupy.
  • Not-enough-valid-pixels error (test_error_all_nan_input, test_error_too_few_valid_pixels): all-NaN input and fewer than n_bands + 1 finite cells both raise ValueError("Not enough valid pixels ...").
  • Degenerate shapes (test_single_pixel_*, test_strip_shapes_match_numpy_dask): 1x1 with provided stats returns the right distance, 1x1 with auto stats raises, and 1xN / Nx1 strips match between numpy and dask.

Test-only, no source changes. 34 tests pass with 0 skips on a GPU host. The cupy and dask+cupy tests carry the existing @cuda_and_cupy_available guard.

…ntrib#3583)

mahalanobis() had complete backend and NaN coverage but left a few
paths untested. Each behaves correctly on a CUDA host, so these are
coverage gaps rather than bugs:

- Inf/-Inf in any band -> NaN output and excluded from auto stats,
  verified identical across all four backends
- the 'Not enough valid pixels' branch for all-NaN and too-few-valid
  inputs
- 1x1 single-pixel (provided stats work, auto stats raise) and 1xN/Nx1
  strips

Test-only. 34 tests pass with no skips on a GPU host.
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.

Test coverage: mahalanobis missing Inf-input, all-NaN, and degenerate-shape tests

1 participant