Repository navigation
Remove un-picklable method in __getstate__ - #3678
jbrockmendel wants to merge 1 commit into
Conversation
Add a test that fails without this fix. In particular, cov_params_func key gets set in fit_regularized. The test is taken directly from GH#2686
|
in general, when we take over commits or PRs, then we should preserve the original author. |
| except (AttributeError, KeyError): | ||
| pass | ||
| # remove unpicklable methods | ||
| self.mle_settings['callback'] = None |
There was a problem hiding this comment.
This removes the try ... except protection for the case when 'callback' is not available.
It doesn't sound like a required key.
There was a problem hiding this comment.
I think, catching the AttributeError was added in case mle_settings itself also doesn't exist.
(I think OLS and similar linear algebra models don't have it but the unit tests don't fail (?).)
There was a problem hiding this comment.
Silly me, that's in discrete_model and not in base All discrete models use currently scipy optimizers and have mle_setting, so there is no failing test case here.
There was a problem hiding this comment.
I'm not clear on why there was a try/except in the first place. KeyError shouldn't occur (maybe confusion with __setstate__?). AttributeError would make sense if there is no mle_settings I guess, but I don't think that case is relevant is it?
There was a problem hiding this comment.
I don't remember if there was a case where it failed.
Maybe it was just risk aversion to imposing details that are not important or required parts of the general interface, i.e. defensive programming. Or it was written in analogy to a base function.
Or just generic future proofness, in case we add estimators that don't define mle_settings and a callback key.
There was a problem hiding this comment.
Better safe than sorry.
I think I want to keep both mle_settings and 'callback' optional. Two extra if won't change performance.
e.g. we, or somebody, might replace the fit method, e.g. if we use GLMNet type of coordinate descend.
What's the appropriate fix? Add a comment in the test? |
Note, I'm making a lot of maintainer comments to you, especially for workflow and details that might not be described or only spread out over parts of the documentation, in case you want to get more into the details of maintenance work. (given that you are already doing a lot of maintenance and review work) I'm not sure yet if we want to fix it here. The way to preserve the original author is to use the initial commits or PR and then add the additional changes in new commits. I.e. my usual workflow is |
To clarify: are my attempts to help being a net drain on your time? If so then I've messed up and will change... something. If not, then I appreciate you helping with my Git-fu.
I've been procrastinating on "real" work by spending time here. I'm going to take this as an excuse to whittle down my statsmodels to-do list for the time being. |
|
@josef-pkt the content of this PR should be good to go. Based on the discussion above it sounds like you want me to add comment(s) somewhere to ensure appropriate attribution. If you can clarify what you're looking for, I'll add it and we can wrap this up. |
|
I will rebase, add two ifs, and get it ready for merge |
Add a test that fails without this fix. In particular, cov_params_func key gets set in fit_regularized.
The test is taken directly from GH #2686