-
Notifications
You must be signed in to change notification settings - Fork 51
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
ENH: expand call signature of cycler() #12
Comments
I think that including #3 makes everything too confusing and hard to remember. #1 and #2 make good sense to me, and I can see #3alt as a reasonable but not essential generalization--and probably not worth the extra complexity in implementation and documentation. I don't see any obvious use case for for which #3alt is advantageous. The use case for #2 is that it facilitates |
Can the c = cycler(pre_existing_Cycler_instance) and c = cycler(**kw) In other words, eliminate the present two-argument form as completely unnecessary when the |
It is still early enough in this project's lifetime to make a complete change like that. It isn't like doing an API change for matplotlib. We can always go back to including positional arguments in the future, if we want it. |
note, I could also implement it where multiple positional arguments (more than one pair) would be excluded. (actually, I already have, I just haven't submitted it yet) |
Just realized that we would need to update the repr's because they use the positional form. Not terrible, but just an additional thing to complete. |
In the discussions going on over in matplotlib/matplotlib#4686, some have asked for the
cycler()
call signature to be expanded a bit. Now, this can be a rabbit hole, so I will break out the proposal into stages so that we can decide just how deep we want to go:Current signature (I call this the simple positional):
cycler(key, vals)
Allow a single kwarg to be equivalent to the current notation:
cycler(k=vals)
Example:
cycler(color='rgb')
vs.cycler('color', 'rgb')
Allow for multiple kwargs (all assumed to be "added" together):
cycler(k1=v1[, k2=v2, ...])
Example:
cycler(color='rgb', lw=[1, 2, 3])
vs.cycler('color', 'rgb') + cycler('lw', [1, 2, 3])
Allow for multiple positional args (all assumed to be "multiplied" together):
cycler(k1, v1[, k2, v2, ...])
Example:
cycler('color', 'rgb', 'lw', [1, 2, 3])
cycler('color', 'rgb') * cycler('lw', [1, 2, 3])
For 2 & 3, I would completely disallow the mixing of positional and keyword arguments.
If we want to avoid having two different operations possible from a single cycler(), we could forgo option 3, and go for the following:
3alt) Allow for both positional and kwargs, but assume all to be "added" together:
cycler(k1, v1[, *args][, k3=v3, **kwargs])
Whichever option (if any) people want, I can put together a PR that implements that. Ideally, I would like to have
cycler.cycler()
to have very similar, if not identical, call signatures to my validating version that I am making in the matplotlib PR referenced above.The text was updated successfully, but these errors were encountered: