-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG + 1] TST test that all default arguments are not mutable #4379
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
Conversation
I'm not sure about functions. They are mutable, but I guess they are fine, right? |
22fd445
to
4bbb52f
Compare
Should wait for #4713, then it will work. |
|
4bbb52f
to
e1ede2f
Compare
ok, should pass now. |
Looks good. |
Merging as minor then. |
e1ede2f
to
90d5ef1
Compare
I just ran into this, because I created a custom estimator that takes an object of a custom class as a default. I wonder whether this should be tested for at all. I understand that the original motivation was to remove mutable default arguments from scikit-learn, but that has been achieved. Note that the test allows functions and Memory objects, which are mutable, because their state is not expected to change. Likewise, the state of the custom objects I use will not change after initialisation, but the test obviously cannot know about that. |
@oulenz A possibly overkill but straightforward solution would be to introduce an estimator tag |
I guess it depends how fine-grained you envision the system of estimator tags. Alternatively, perhaps an opt-out list of tests for individual estimators could be a more general solution. |
Or just not including this one in the non-strict mode as @rth suggested. I think depending on names of tests is bad because multiple tests test the same thing or rely on similar assumptions and we'll get in a real mess if we try that. We should encode our assumptions about the estimator, not what specific tests to run. |
Check that default parameter values are of a basic type.
See #4376 for a fix for one of them, #4373 for the issue.