Refactor: Centralize local model initialization in _BaseModel - #99
Closed
jigyasaba wants to merge 6 commits into
Closed
Refactor: Centralize local model initialization in _BaseModel#99jigyasaba wants to merge 6 commits into
jigyasaba wants to merge 6 commits into
Conversation
up# the commit. all clean
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #99 +/- ##
==========================================
+ Coverage 92.96% 93.09% +0.12%
==========================================
Files 6 6
Lines 825 825
==========================================
+ Hits 767 768 +1
+ Misses 58 57 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
It is duplicated but explicit. Anyone reading the code immediately gets it without figuring out what does the private method do. Any PR shall have a linked and approved issue. Closing as this one does not. |
Contributor
Author
|
Thank you for the clarification, I understand the preference for explicitness in the fit loops over the DRY refactor here. I also appreciate the reminder on the workflow—I will ensure all future PRs are linked to an approved issue first. |
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.
Description:
While reviewing the BaseClassifier and BaseRegressor implementations, I noticed the logic for inspecting random_state during local model initialization was duplicated.
I have refactored this into a helper method _initialize_local_model in the parent _BaseModel class. This adheres to the DRY principle and simplifies the _fit_local loop in both subclasses, making the codebase easier to maintain as we add new modules.
Validation:
Verified that random_state is correctly passed to models that support it.
Ran pytest gwlearn/tests/test_base.py and all 112 tests passed.