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

Implement a kwargs converter to take a list and create multiple "-Bla" entries #21

Closed
leouieda opened this issue Jul 11, 2017 · 2 comments
Labels
good first issue Good for newcomers help wanted Helping hands are appreciated

Comments

@leouieda
Copy link
Member

leouieda commented Jul 11, 2017

Some arguments are meant to be passed twice, for example -I1/1p,blue -I2/0.25p,blue. This can't happen in Python. The way to fix this is to add a converter to kwargs_to_strings in gmt/utils.py that takes a list (I=['1/1p,blue', '2/0.25p,blue']) and creates multiple entries in the argument list.

@leouieda leouieda added good first issue Good for newcomers help wanted Helping hands are appreciated labels Dec 7, 2017
@seisman
Copy link
Member

seisman commented Dec 20, 2017

Two possible ways to fix this issue:

  1. Add another conversion (for example multi_entries) in kwargs_to_string and convert keywords argument {'I': ['1/1p,blue', '2/0.25p,blue']} to string -I1/1p,blue -I2/0.25p,blue. Meanwhile delete {'I': ['1/1p,blue', '2/0.25p,blue']} from **kwargs and append -I1/1p,blue -I2/0.25p,blue to *args.

  2. Do nothing in kwargs_to_strings but do the conversion in build_arg_string. If the value of a argument is a list, then convert it multiple times (from {'I': ['1/1p,blue', '2/0.25p,blue']} to -I1/1p,blue -I2/0.25p,blue).

Which one do you prefer?

@leouieda
Copy link
Member Author

It would fit better in kwargs_to_string but that won't work because we can't have multiple I entries in a dict. So it's better to do this in build_arg_string. You can use is_nonstr_iter to check and then make multiple entries. Thanks for taking a look at this.

For arguments like -B, I'm thinking of making Bx and By separate arguments with their own aliases framex, framey. But for some, like the -I example, this doesn't work.

leouieda pushed a commit that referenced this issue Jan 10, 2018
Fixes #21

Implemented in build_arg_string instead of kwargs_to_strings because
we can't have multiple entries in a dictionary with the same key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Helping hands are appreciated
Projects
None yet
Development

No branches or pull requests

2 participants