Skip to content

Expand unit testing with hypothesis and edge case coverage#88

Merged
monte-flora merged 1 commit into
masterfrom
improve/testing-and-categorical-fix
Apr 2, 2026
Merged

Expand unit testing with hypothesis and edge case coverage#88
monte-flora merged 1 commit into
masterfrom
improve/testing-and-categorical-fix

Conversation

@monte-flora
Copy link
Copy Markdown
Owner

Add 46 new tests (109 total, up from 63) covering:

  • ExplainToolkit init edge cases: unfitted models, bare estimators, numpy arrays, non-contiguous indices, y as list/Series
  • PlotConfig API: set/get/reset, invalid keys, persistence
  • Return type consistency: all compute methods return xarray.Dataset, computation_time_seconds in attrs
  • Validation helpers: normalize_features/normalize_estimator_names with hypothesis property-based testing (random strings, lists)
  • to_skexplain_importance: 1D/2D arrays, SHAP sum, normalization
  • ALE property-based: varying n_features (2-8), n_bins (3-20), subsample fractions (0.1-1.0) via hypothesis
  • Permutation importance: rankings length matches n_vars, uniqueness of rankings
  • SAGE: basic, grouped, package availability check
  • IO round-trip: save/load netCDF preserves values
  • Grouping utilities: shape, scaling, local value grouping
  • Degenerate inputs: constant features, single-feature datasets, 2-sample minimal datasets
  • High-cardinality categorical ALE (issue Calculating ALE for high cardinality categorical feature throw a ValueError #86 regression tests)

Add hypothesis and sage-importance to requirements.txt for CI. Fix missing unittest import in test_interpret_curves.py.

Add 46 new tests (109 total, up from 63) covering:

- ExplainToolkit init edge cases: unfitted models, bare estimators,
  numpy arrays, non-contiguous indices, y as list/Series
- PlotConfig API: set/get/reset, invalid keys, persistence
- Return type consistency: all compute methods return xarray.Dataset,
  computation_time_seconds in attrs
- Validation helpers: normalize_features/normalize_estimator_names
  with hypothesis property-based testing (random strings, lists)
- to_skexplain_importance: 1D/2D arrays, SHAP sum, normalization
- ALE property-based: varying n_features (2-8), n_bins (3-20),
  subsample fractions (0.1-1.0) via hypothesis
- Permutation importance: rankings length matches n_vars,
  uniqueness of rankings
- SAGE: basic, grouped, package availability check
- IO round-trip: save/load netCDF preserves values
- Grouping utilities: shape, scaling, local value grouping
- Degenerate inputs: constant features, single-feature datasets,
  2-sample minimal datasets
- High-cardinality categorical ALE (issue #86 regression tests)

Add hypothesis and sage-importance to requirements.txt for CI.
Fix missing unittest import in test_interpret_curves.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@monte-flora monte-flora merged commit 2f0a58a into master Apr 2, 2026
11 checks passed
@monte-flora monte-flora deleted the improve/testing-and-categorical-fix branch April 2, 2026 12:11
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