Commit e7fbec0
refactor: LC2ST module refactoring with states (#1727)
* fix flaky test
* fix: correct typos and improve error handling.
* feat: enhance LC2ST with new state management and structured score return type
* refactor: streamline normalization process and enhance classifier defaults
* refactor: enhance LC2ST test structure with dataclasses for setup and calibration
* fix: correct typos and enhance documentation in LC2ST class
* refactor tests
* refactor: LC2ST class and related tests for improved clarity and functionality
- Updated parameter names in LC2ST initialization for consistency (thetas -> prior_samples).
- Modified get_scores and get_statistics_under_null_hypothesis methods to return LC2STScores objects, encapsulating probabilities and scores.
- Adjusted usage of get_scores in the tutorial and tests to reflect the new return type.
- input validation in LC2ST to prevent indexing errors.
- Updated tests to assert the presence of scores in the returned null statistics.
* fix: address review remarks on LC2STstate and nb
Fixes three merge blockers from review:
- LC2ST_NF(trained_clfs_null=...) was deadlocked: __init__ left _state
at INITIALIZED when pretrained null classifiers were passed, so
train_on_observed_data advanced to OBSERVED_TRAINED (not READY) and
p_value raised. Now advances to NULL_TRAINED when pretrained
classifiers are supplied.
- train_on_observed_data downgraded READY -> OBSERVED_TRAINED on
retrain, breaking the documented loop-over-seeds workflow from the
tutorial. READY is now preserved.
- Advanced-tutorial notebook called np.quantile / axes.hist on the new
LC2STScores return value. Both failing cells now extract .scores.
* style: ruff format new LC2ST regression tests
* fix: address LC2ST review remarks on API and types
- Narrow get_scores / get_statistics_under_null_hypothesis return type
to Union[LC2STScores, Tuple[np.ndarray, np.ndarray]]; the bare
np.ndarray branch was never returned.
- Clarify return_probs deprecation warning to mention the (probs,
scores) tuple order and the eventual removal.
- Guard z-score normalization against constant feature dimensions:
std == 0 is replaced by 1.0 so constant columns become pass-through
(mean-centered) instead of producing NaN/Inf.
- Rewrite the error message raised when re-entering
train_under_null_hypothesis so it applies cleanly to both LC2ST
(permutation, data-dependent) and LC2ST_NF (analytical, reusable).
- Fix docstring: verbosity in get_statistics_under_null_hypothesis
defaults to 0, not 1.
- Add regression tests for single-normalization in null training,
constant-dim normalization robustness, and document the
lc2st_instance fixture scope.
* fix: use FutureWarning for user-facing LC2ST deprecations
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 8facb74 commit e7fbec0
5 files changed
Lines changed: 1242 additions & 436 deletions
File tree
- docs
- advanced_tutorials
- how_to_guide
- sbi/diagnostics
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | 307 | | |
309 | 308 | | |
| 309 | + | |
| 310 | + | |
310 | 311 | | |
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
317 | | - | |
| 318 | + | |
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
386 | | - | |
| 387 | + | |
387 | 388 | | |
388 | 389 | | |
389 | | - | |
390 | 390 | | |
391 | | - | |
392 | | - | |
| 391 | + | |
| 392 | + | |
393 | 393 | | |
394 | | - | |
395 | | - | |
396 | | - | |
| 394 | + | |
| 395 | + | |
397 | 396 | | |
398 | 397 | | |
399 | 398 | | |
| |||
451 | 450 | | |
452 | 451 | | |
453 | 452 | | |
454 | | - | |
| 453 | + | |
455 | 454 | | |
456 | 455 | | |
457 | | - | |
458 | 456 | | |
459 | | - | |
| 457 | + | |
460 | 458 | | |
461 | 459 | | |
462 | 460 | | |
| |||
543 | 541 | | |
544 | 542 | | |
545 | 543 | | |
546 | | - | |
| 544 | + | |
547 | 545 | | |
548 | 546 | | |
549 | 547 | | |
| |||
612 | 610 | | |
613 | 611 | | |
614 | 612 | | |
615 | | - | |
| 613 | + | |
616 | 614 | | |
617 | 615 | | |
618 | 616 | | |
| |||
660 | 658 | | |
661 | 659 | | |
662 | 660 | | |
663 | | - | |
| 661 | + | |
664 | 662 | | |
665 | | - | |
666 | 663 | | |
667 | 664 | | |
| 665 | + | |
| 666 | + | |
668 | 667 | | |
669 | | - | |
| 668 | + | |
670 | 669 | | |
671 | 670 | | |
672 | 671 | | |
| |||
731 | 730 | | |
732 | 731 | | |
733 | 732 | | |
734 | | - | |
| 733 | + | |
735 | 734 | | |
736 | | - | |
737 | 735 | | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
743 | 740 | | |
744 | 741 | | |
745 | 742 | | |
| |||
791 | 788 | | |
792 | 789 | | |
793 | 790 | | |
794 | | - | |
| 791 | + | |
795 | 792 | | |
796 | | - | |
797 | 793 | | |
798 | | - | |
| 794 | + | |
799 | 795 | | |
800 | 796 | | |
801 | 797 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
97 | | - | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
0 commit comments