Add classify edge-case and error-path test coverage#3417
Merged
Conversation
Tests only; classify.py is untouched. The backend matrix was already complete for all ten classifiers across the four backends, so the gaps were elsewhere. New tests: - 1x1 single-pixel and Nx1 / 1xN strip shapes for every classifier (these degenerate shapes were untested) - the k-below-minimum validation guards (quantile/natural_breaks/ maximum_breaks require k>=2, equal_interval requires k>=1), which previously had no error-path test All new tests run and pass on a CUDA host; the full file reports 98 passed. Deep-sweep test-coverage, module: classify.
…age-classify-2026-06-20 # Conflicts: # xrspatial/tests/test_classify.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Test-only additions for
xrspatial/classify.py. The source is untouched.A deep-sweep test-coverage pass found the backend matrix was already complete: all ten public classifiers (binary, reclassify, quantile, natural_breaks, equal_interval, std_mean, head_tail_breaks, percentiles, maximum_breaks, box_plot) run across numpy, dask+numpy, cupy, and dask+cupy with parity assertions. NaN/Inf and metadata preservation are also covered. The gaps were in geometric edge cases and validation error paths.
New tests
Geometric edge cases (Cat 3, MEDIUM):
test_classify_single_pixel/test_binary_single_pixel/test_reclassify_single_pixel-- 1x1 raster for every classifiertest_classify_nx1_strip/test_classify_1xn_strip-- single-column and single-row stripsValidation error paths (Cat 4, MEDIUM):
test_quantile_k_below_min_raises,test_natural_breaks_k_below_min_raises,test_maximum_breaks_k_below_min_raises(k must be >= 2)test_equal_interval_k_below_min_raises(k must be >= 1)These guards were never exercised; only reclassify's length-mismatch check and the "not enough unique values" fallback were.
Verification
All new tests run and pass on a CUDA host. The full
test_classify.pyreports 98 passed. Probing the edge shapes live showed they all behave correctly, so no source bug was found and none is filed.