-
Notifications
You must be signed in to change notification settings - Fork 235
Disallow passing arguments like -XNone to GMT #639
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
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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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=Noneshould return the same result asX=False, following what was suggested at #380 (comment).Question is, should the
Nonedetection logic be placed here, or would it be better to put it inremove_boolssomewhere 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
Noneor even boolean values in thekwargs_to_stringsdecorator.Uh oh!
There was an error while loading. Please reload this page.
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_stringsdecorator, 2) some PyGMT virtualfile logic or whatever, and then 3) thebuild_arg_stringwhich passes things to GMT C API.In (1), the
kwargs_to_stringhas aremove_boolssetting that turnsTrueinto an empty string"", are you suggesting in #640 that we should not perform thatTrueto""conversion in (1), but move it to (3) atbuild_arg_stringinstead? Similarly in this PR,Nonehas to be handled later at step (3) inbuild_arg_string, rather than at step (1) inkwargs_to_string/remove_bools.Uh oh!
There was an error while loading. Please reload this page.
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_argsshould beTrueorFalse. However, when calling the function, the decoratorkwargs_to_stringconvertsnongmt_args=Truetonongmt_args="". It makes sense ifnongmt_argsis an alias of GMT options (e.g.,-N), so that we can pass-Nto GMT. However, whennongmt_argsis just a Python variable, the conversion means checkingnongmt_argsis 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/Falseinputs will eventually need to go here inbuild_arg_stringsas well? It seems weird to have bothkwargs_to_stringsandbuild_arg_stringshandling 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_stringsis incorrect, and we should fix #640 by moving the True/False conversion tobuild_arg_strings(but in a separate PR).Uh oh!
There was an error while loading. Please reload this page.
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.