Uh oh!
There was an error while loading. Please reload this page.
Conversation
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).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if angle is True: | ||
| kwargs["F"] += "+a" | ||
| elif isinstance(angle, (int, float, str)): | ||
| kwargs["F"] += f"+a{str(angle)}" |
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:
| ifangleisTrue: | |
| kwargs["F"] +="+a" | |
| elifisinstance(angle, (int, float, str)): | |
| kwargs["F"] +=f"+a{str(angle)}" | |
| ifangle: | |
| kwargs["F"] +="+a" | |
| ifisinstance(angle, (int, float, str)): | |
| kwargs["F"] +=str(angle) |
| if font is True: | ||
| kwargs["F"] += "+f" | ||
| elif isinstance(font, str): | ||
| kwargs["F"] += f"+f{font}" |
There was a problem hiding this comment.
| iffontisTrue: | |
| kwargs["F"] +="+f" | |
| elifisinstance(font, str): | |
| kwargs["F"] +=f"+f{font}" | |
| iffont: | |
| kwargs["F"] +="+f" | |
| ifisinstance(font, str): | |
| kwargs["F"] +=font |
| if justify is True: | ||
| kwargs["F"] += "+j" | ||
| elif isinstance(justify, str): | ||
| kwargs["F"] += f"+j{justify}" |
There was a problem hiding this comment.
| ifjustifyisTrue: | |
| kwargs["F"] +="+j" | |
| elifisinstance(justify, str): | |
| kwargs["F"] +=f"+j{justify}" | |
| ifjustify: | |
| kwargs["F"] +="+j" | |
| ifisinstance(justify, str): | |
| kwargs["F"] +=justify |
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
…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>
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