-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Make check_parameters_default_constructible more lenient regarding accepted types #25467
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
Comments
Solving this issue will solve the remaining failure of |
Hello, can I work on this issue ? |
@shamzos probably not the best issue to work on, you can look at the issues tagged "good first issue". Have a look at https://scikit-learn.org/dev/developers/contributing.html for more details. |
Is there a reason why it has to be a |
No, but this is not the same pattern used. Right now we check if the type is in a given set of types. assert type(init_param.default) in allowed_types or callable(init_param.default) |
Yes, you'd have to rewrite it. But it seemed like that would be easy (in terms of making the edit) compared to understanding if this is "the right thing to do". |
It seems like we are trying to avoid the Python gotcha with default mutable arguments but at the same time we accept functions as default arguments which are potentially mutable so ... Allowing callables would accept an even wider class of mutable objects. Honestly I don't know what to do about this test, maybe two main options:
Quickly checking there are 7 estimators that use functions as default arguments (removing
|
I think I'd be permissive. The main trap(?) is mutable default arguments, so things like lists that end up being shared. I'm not sure the same trap exists for functions, for functions (or callables) the problem is much worse: who knows what they are doing, independent of them being defined as default value. Another aspect that could be relevant: is there a constraint on the default arguments of an estimator because of how |
I don't think so but I could be wrong. Also I am quite sure that there are common tests checking that estimators can be pickled which would catch such an issue. |
So let's go by checking if this is a |
See discussions and decision of: scikit-learn#25467 Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> Co-authored-by: Loïc Estève <loic.esteve@ymail.com> Co-authored-by: From: Tim Head <betatim@gmail.com>
With the nightly build of
numpy
, we have the following error raised:I think this is linked with the integration of: numpy/numpy#23020
Now, the
np.func
are of type_ArrayFunctionDispatcher
and notfunction
anymore. This is a kind of regression but I assume that we could make our test more lenient and accept those types of input.The only issue is that this dispatcher is private so I don't think this is a bright idea to add it to our test as is.
The text was updated successfully, but these errors were encountered: