-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNT] Refactor .clone()
#281
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #281 +/- ##
==========================================
- Coverage 85.07% 84.62% -0.46%
==========================================
Files 45 45
Lines 3015 3050 +35
==========================================
+ Hits 2565 2581 +16
- Misses 450 469 +19 ☔ View full report in Codecov by Sentry. |
Nice, thanks! Btw, I'm not sure I remember where the "check clone" code is coming from. I added the config to ignore it by default but still have it there just in case. I always thought it is sth from |
@fkiraly thanks for taking a look at this already. I opened a draft PR just because I wanted to start typing some notes in the description.
It’s a bit strange indeed. It doesn’t seem like the right place to run such checks. If these checks ever fail it’s because the BaseObject’s implementation is not compliant with the scikit estimator protocol which requires all params passed to the constructor to be set as instance variables “as is” during instantiation. Having these checks at runtime during a cloning call seems quite arbitrary and out of place (and unnecessary overhead). If someone wants to check whether their estimator is scikit-compliant, this should probably happen in a test suite and maybe a helper function could be provided (maybe already exists?). Also, the check only runs for |
Ah, I remember! I agree with you and that's why I turned it into an opt-in configurable feature. When we refactored the base classes from I did not add that test (it was @RNKuhns), I believe they were added because back then Then we removed the |
Thanks for the background! What's your take, should this be deprecated and removed in a future version? Or you see value in leaving it in? |
Hm, I would say, let's deprcate, given that it seems gone in This could be |
@fkiraly For the reasons mentioned above, I think that moving the cloning logic to a separate function makes sense. In that regard, this PR would be ready to review and merge. However, after doing a quick scan through the codebase, it seems like the use of the term 'estimator' is misused in a few places. I guess that abstracting Some of these references are easy to fix (just replace "estimator" with something else {"base object"?}). See tpvasconcelos#2 for example. However, both Thoughts? |
Makes sense - do you want ot turn it done then, and resolve the QL issues?
Yes - the history is that, initially only estimators (with "fit") were inheriting from a In creating |
So, @tpvasconcelos, if you're done - could you remove the WIP tag and turn the PR to ready? Just to make sure we're not merging something incomplete. |
Opened! |
(no major change, just moved |
…more general references (#293) #### Reference Issues/PRs Depends on #281 #### What does this implement/fix? Explain your changes. See #281 (comment) and relevant replies.
Reference Issues/PRs
#280
What does this implement/fix? Explain your changes.
.clone()
's implementation to 3 easy-to-understand steps:self
check_clone
, run extra checks_check_clone()
function._check()
method into a private_check()
function._check()
implementation was not accessing any instance (self
) attributes or methods. It would only recursively call itself again asself._clone(...)
, in practice making it a static method.Does your contribution introduce a new dependency? If yes, which one?
What should a reviewer concentrate their feedback on?
Any other comments?
PR checklist
For all contributions
the PR topic is related to enhancement, CI/CD, maintenance, documentation, or a bug.
For code contributions