-
Notifications
You must be signed in to change notification settings - Fork 224
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
Disallow passing arguments like -XNone to GMT #639
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
X=None
should return the same result asX=False
, following what was suggested at #380 (comment).Question is, should the
None
detection logic be placed here, or would it be better to put it inremove_bools
somewhere here:pygmt/pygmt/helpers/decorators.py
Lines 436 to 443 in 1bf0a30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#640 explains why we can't deal with
None
or even boolean values in thekwargs_to_strings
decorator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very confusing 😕, so for most PyGMT modules, we go through 1)
kwargs_to_strings
decorator, 2) some PyGMT virtualfile logic or whatever, and then 3) thebuild_arg_string
which passes things to GMT C API.In (1), the
kwargs_to_string
has aremove_bools
setting that turnsTrue
into an empty string""
, are you suggesting in #640 that we should not perform thatTrue
to""
conversion in (1), but move it to (3) atbuild_arg_string
instead? Similarly in this PR,None
has to be handled later at step (3) inbuild_arg_string
, rather than at step (1) inkwargs_to_string
/remove_bools
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as shown in #640, the boolean argument
nongmt_args
should beTrue
orFalse
. However, when calling the function, the decoratorkwargs_to_string
convertsnongmt_args=True
tonongmt_args=""
. It makes sense ifnongmt_args
is an alias of GMT options (e.g.,-N
), so that we can pass-N
to GMT. However, whennongmt_args
is just a Python variable, the conversion means checkingnongmt_args
is True or False won't work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I just updated the codes in #640, hopefully, to make the issue easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So reading #640, does that mean that
True
/False
inputs will eventually need to go here inbuild_arg_strings
as well? It seems weird to have bothkwargs_to_strings
andbuild_arg_strings
handling different pieces of Python to GMT logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Yes, as mentioned in #640, handling boolean arguments in
kwargs_to_strings
is incorrect, and we should fix #640 by moving the True/False conversion tobuild_arg_strings
(but in a separate PR).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this PR should be fine then for now. I'll approve it but you'll need to update the branch in order to merge.