Skip to content
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

keyword argument aliases and pluralization #15

Closed
tbreloff opened this issue Sep 15, 2015 · 3 comments
Closed

keyword argument aliases and pluralization #15

tbreloff opened this issue Sep 15, 2015 · 3 comments

Comments

@tbreloff
Copy link
Member

Use mod1(argOptions) to cycle through the choices. Current behavior shouldn't change, but you could, for example, do:

plot(randn(1000, 10); linestyles=[:solid, :dash])

And it would alternate between the styles... 5 solid, 5 dash.

Could also take this opportunity to do away with the pluralized form (or at least map AbstractVector inputs to the pluralized form automatically).

@tbreloff
Copy link
Member Author

Part 1 is done... still need to address "Could also take this opportunity to do away with the pluralized form (or at least map AbstractVector inputs to the pluralized form automatically)"

@tbreloff
Copy link
Member Author

On this same note, I think it would be nice to have a preliminary layer which converts alternative names into the "one true name" for keyword keys and values. So for example:

(:c, :r) --> (:colors, [:red])
(:c, [:r,:b])  --> (:colors, [:red,:blue])
(:t, :l) --> (:linetypes, [:line])
(:type, :s) --> (:linetypes, [:scatter])
  etc...

Then syntax could be super short:

plot(y, c=:r)

The one gotcha to look out for... if I want to pass an array of colors for one series (say, for a colorscheme), then I need a way to pass in an array and have it be treated as a single value by the "renaming layer". This is the single most important reason that I still have explicit pluralized arguments. With a good solution I will merge plural and singular versions so they both do the same thing.

@tbreloff
Copy link
Member Author

A clunky solution would be to require the user to wrap "array values" explicitly if the whole array should be applied to one series. So then:

(:c, :r) --> (:colors, [colorant"red"])
(:c, [:r, :b]) --> (:colors, [colorant"red", colorant"blue"])
(:c, [[:r, :b]]) --> (:colors, [[colorant"red", colorant"blue"]])

In the 1st and 2nd cases, the odd series would get the one color red while the even series would get the one color blue. In the 3rd case, all series would get the full vector of [red,blue]

@tbreloff tbreloff changed the title Allow pluralized args shorter than the number of series keyword argument aliases and pluralization Sep 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant