Open
Conversation
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
…tionality - 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.
Resolved conflicts integrating GPU support (PR #1715) into the refactored LC2ST code: - Added device parameter to LC2ST.__init__ with GPU detection - Integrated NeuralNetBinaryClassifier for GPU-accelerated training - Added skorch ValidSplit and EarlyStopping configuration - Fixed target dtype for skorch (float32) vs sklearn (int64) - Updated tests to use refactored cal_data fixture 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
LC2ST Module Refactoring
Summary
This PR refactors the LC2ST diagnostics module to improve API clarity, error handling, and maintainability while preserving full backward compatibility.
Note 1: I used Claude Code with this refactoring. Every commit was reviewed by me and a very critical Gemini Pro reviewing agent. I believe the changes here are very useful and correct, but the reviewer should please take extra care and be extra skeptical when reviewing this.
Note 2: I started this in parallel or motivated by the flaky test spotted in #1715 , so we need to resolve potential conflicts between these PRs down the line.
Motivation
The LC2ST implementation had accumulated several issues:
assertstatements, which are stripped in optimized buildsget_scores()returned different types based on a boolean flagDesign Choices
State Machine (
LC2STStateenum): Rather than documenting method call order, the refactoring enforces it through explicit state transitions. The LC2ST object progresses throughINITIALIZED → OBSERVED_TRAINED/NULL_TRAINED → READY, with methods checking state before execution. Both training orders are valid and reachREADY.Structured Returns (
LC2STScoresdataclass): Replaces theUnion[array, Tuple[array, array]]return type with a dataclass containingscoresand optionalprobabilities. The oldreturn_probs=Truebehavior is preserved but deprecated.Parameter Rename with Deprecation:
thetas→prior_samplesfor clarity (it's samples from the prior, not parameters). The old parameter works via keyword-only argument withDeprecationWarning.DRY Normalization: Extracted
_normalize_theta()and_normalize_x()helpers. Normalization now happens exactly once in_train()andget_scores(), fixing the double-normalization bug.Validation via Exceptions: All
assertstatements replaced withValueError/TypeErrorwith actionable messages citing actual vs expected values.Backward Compatibility
thetas=...keyword works with deprecation warningget_scores(..., return_probs=True)works with deprecation warningTest Improvements
Reduced parametrization from 48 combinations to 28 focused tests using pytest patterns (dataclass fixtures, composable fixture hierarchy, parametrized validation tests).