Conversation
weiji14
reviewed
Mar 26, 2021
Member
weiji14
left a comment
There was a problem hiding this comment.
Just some minor comments for now. I think there's some room for improvement but will suggest more later (possibly after the weekend).
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
weiji14
reviewed
Apr 5, 2021
Member
weiji14
left a comment
There was a problem hiding this comment.
A few suggestions, mostly on refactoring the if-then blocks. Feel free to disagree if it feels less readable to you.
Comment on lines
+180
to
184
|
|
||
| if angle is True: | ||
| kwargs["F"] += "+a" | ||
| elif isinstance(angle, (int, float, str)): | ||
| kwargs["F"] += f"+a{str(angle)}" |
Member
There was a problem hiding this comment.
Just thinking ahead to resolve #483 (allowing list inputs to angle/list/justify), we could simply use if angle (returns True for list/int/float/str inputs) like so:
Suggested change
| if angle is True: | |
| kwargs["F"] += "+a" | |
| elif isinstance(angle, (int, float, str)): | |
| kwargs["F"] += f"+a{str(angle)}" | |
| if angle: | |
| kwargs["F"] += "+a" | |
| if isinstance(angle, (int, float, str)): | |
| kwargs["F"] += str(angle) |
Member
Author
Comment on lines
+186
to
189
| if font is True: | ||
| kwargs["F"] += "+f" | ||
| elif isinstance(font, str): | ||
| kwargs["F"] += f"+f{font}" |
Member
There was a problem hiding this comment.
Suggested change
| if font is True: | |
| kwargs["F"] += "+f" | |
| elif isinstance(font, str): | |
| kwargs["F"] += f"+f{font}" | |
| if font: | |
| kwargs["F"] += "+f" | |
| if isinstance(font, str): | |
| kwargs["F"] += font |
Comment on lines
+191
to
194
| if justify is True: | ||
| kwargs["F"] += "+j" | ||
| elif isinstance(justify, str): | ||
| kwargs["F"] += f"+j{justify}" |
Member
There was a problem hiding this comment.
Suggested change
| if justify is True: | |
| kwargs["F"] += "+j" | |
| elif isinstance(justify, str): | |
| kwargs["F"] += f"+j{justify}" | |
| if justify: | |
| kwargs["F"] += "+j" | |
| if isinstance(justify, str): | |
| kwargs["F"] += justify |
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
8 tasks
sixy6e
pushed a commit
to sixy6e/pygmt
that referenced
this pull request
Dec 21, 2022
…ngs (GenericMappingTools#1125) * Do not convert booleans in the kwargs_to_strings decorator * Deal with boolean values in build_arg_string * load_earth_relief no longer need the convert_bools=False hack * Fix the weird codes in subplot autolabel * Fix the weird codes in text Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of proposed changes
See #640 and #639 (the discussions and the fix) for context.
Changes in this PR:
convert_boolsparameter fromkwargs_to_strings. Sokwargs_to_stringswon't convert boolean arguments.build_arg_stringfunction.use_srtmparameter ofload_earth_reliefwon't be converted to an empty string or removed anymore. Now it's safe to checkif use_strm.autolabelparameter ofsubplotfunction can be either bool or str, but we had to check ifautolabel is not None. It's not intuitive. Actually, we made a mistake in the initial version (4126c16) and then fixed it (eadb847).justify,angle, andfontcan be boolean, but we have to check if it'sNone. This commit also fixes the weird codes.Fixes #640.
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version