-
Notifications
You must be signed in to change notification settings - Fork 229
Change text when GMTInvalidInput error is raised for basemap #729
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
seisman
merged 19 commits into
GenericMappingTools:master
from
willschlitzer:baseplotting-error
Dec 15, 2020
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7be1d62
Change error text for basemap GMTInvalidInput
willschlitzer 32edc8e
Remove rose from basemap GMTInvalidInput error; adding "rose" or "com…
willschlitzer 815876b
Add basemap GMTInvalidInput exception if region is not specified.
willschlitzer c9831b0
Rewrite if statement for R in kwargs under basemap
willschlitzer 5efce1c
Removing "At least" from GMTInvalidInput error text since numbers are…
willschlitzer ed798ad
Remove "T in kwargs" from if not statement, as "T" is not an availabl…
willschlitzer 41e8d48
Remove reqion error raising for basemap()
willschlitzer 6de6750
Update if statement and error text for compass or rose
willschlitzer bf054c2
Merge branch 'master' into baseplotting-error
willschlitzer d0dc60b
Run make format
willschlitzer 5a705bc
Add test_basemap_compass() and test_basemap_rose()
willschlitzer 8abd940
Run make format
willschlitzer fb5abf4
Change GMTInvalidInput error text for basemap in base_plotting.py
willschlitzer 7de49a5
Fix tests in test_basemap.py
willschlitzer 10b59fe
Adding comparison images that I forgot to add
willschlitzer 375aa73
Rewrite compass and rose tests to use @check_figures_equal() and dele…
willschlitzer ca740d5
Update pygmt/tests/test_basemap.py
willschlitzer acac815
Update pygmt/tests/test_basemap.py
willschlitzer 412e390
Merge branch 'master' into baseplotting-error
willschlitzer 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.
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.
We actually have
Tm
andTd
, but agree that the error message should be reworded.pygmt/pygmt/base_plotting.py
Lines 1120 to 1121 in 2128dd4
Not sure if we should have separate checks for
"Td"
and"Tm"
though, or if"T"
is enough? Could you stress test this?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.
@weiji14 I mentioned
Tm
andTd
in #730 as what I assume are the aliases being referred to withT
. I'm not familiar with therose
andcompass
arguments and haven't managed to plot them on a map, but I have at least had them run without raising an error.I passed:
fig.basemap(region=[0, 10, 0, 10], frame="af", compass="x1/2/1")
and
fig.basemap(region=[0, 10, 0, 10], frame="af", rose="x1/2/1")
Both of these ran without an error (although I couldn't get the compass or rose to actually plot), but the
GMTInvalidInput
was raised when I deletedframe
.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.
See if this test case provides some inspiration (this was written quite a while ago before the compass/ross alias was done):
pygmt/pygmt/tests/test_config.py
Lines 61 to 70 in e6d45ec
Basically something like
fig.basemap(compass="jBR+w5c+d-4.5")
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.
@weiji14 I'll take a look at this tomorrow.
Also, is there any reason the tests use the GMT aliases instead of the PyGMT parameters when calling functions? I was to try and add tests for map_scale, compass, and rose arguments to make sure the error isn't raised when they're passed.
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.
Part of the reason is historical. We did a big purge of short aliases in #474 on the user-facing side, but haven't got around to fixing the backend tests. That said, there are some tests which do explicitly use short GMT aliases, but the one I linked above should not be one of them.
TLDR: Use long aliases unless there's a reason to use short ones.
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.
@weiji14 Thanks for the info!
Regarding stress testing GMT accepting Td/Tm values, is there any easy way to use the pygmt folder from my repo in the environment instead of v0.2.1 that I have in my conda environment, or is writing good tests the better solution here? I'm not opposed to writing tests, but it's a lengthy process to have to wait for tests to run after pushing a commit.
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.
You can activate your conda environment, run
cond uninstall pygmt
to uninstall the v0.2.1 version, and then change into your pygmt folder, and reinstall pygmt usingpip install -e .
. The command installs pygmt to your environment in "editable/developing" mode. Now in the conda environment, you can use the pygmt master or any other branches.You don't have to rely on the CI tests. Instead, you can run all tests locally by running
make test
, or run tests in a specific file bypytest pygmt/tests/test_coast.py
.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.
If you do
make install
(i.e.pip install -e
), that will installPyGMT
in 'editable' mode so any changes should work once you reload thePyGMT
library or useimportlib.reload
. As for tests, you can run just one file at a time following https://github.com/GenericMappingTools/pygmt/blob/master/CONTRIBUTING.md#testing-your-code, @seisman just simplified things with #725: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.
Thanks for the help with this! It looks like compass and rose do not individually satisfy the requirement and the error is still raised. Working on updating my pull request.