[scikit-learn] Vote on SLEP009: keyword only arguments

Andreas Mueller t3kcit at gmail.com
Wed Sep 18 11:34:18 EDT 2019



On 9/17/19 3:42 AM, Joel Nothman wrote:
> I think you mean keyword-only, Alex
>
> On Tue., 17 Sep. 2019, 4:11 pm Alexandre Gramfort, 
> <alexandre.gramfort at inria.fr <mailto:alexandre.gramfort at inria.fr>> wrote:
>
>     Yes I am +1 for positional arguments for the __init__ of the
>     estimators.
>
>     Alex
>
>
>
> Albert: my position when reviewing changes in accordance with this 
> SLEP would be to (a) perhaps get usage evidence as discussed in the 
> SLEP pull request review; and (b) apply a rule of thumb like "are the 
> semantics reasonably clear when the argument is passed positionally?" 
> I think they are clear for PCA's components, for Pipeline's steps, and 
> for GridSearchCV's estimator and parameter grid. Other parameters of 
> those estimators seem more suitable for keyword-only.
I think you're not fully addressing Albert's concern, which I think is 
quite important and hasn't been brought up before.

I think Albert is saying that it should be easy for a new user to build 
a mental model of when a positional argument is allowed.
If we can't specify a simple rule, then it's very hard for a new (or 
really any) user to have clear expectations.
And I think sklearn is all about setting clear expectations.

 > Also how  is this going to be rendered by sphinx in the doc?

There will be a star in the signature between positional and kw only 
args i.e. PCA(n_components=2, *, copy=True, ...)
So you could always look at the docs to figure it out. That's clearly 
not very convenient.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20190918/1b13d5fc/attachment-0001.html>


More information about the scikit-learn mailing list