-
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
pygmt.dataset.load_*: Add type hints for the 'region' parameter #3272
Conversation
Will apply the same changes to other Edit: Applied to all load_functions in 4ddf1f9 |
|
||
__doctest_skip__ = ["load_earth_age"] | ||
|
||
|
||
@kwargs_to_strings(region="sequence") |
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 line can be removed because region
is passed to _load_remote_dataset
and in that function region
can be a sequence.
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.
Passing a list or a tuple is definitely more Pythonic.
But I am wondering how we want to handle arguments containing ISO codes and arguments extending a region via appending +r
, e.g., lon_min/lon_ma/lat_min/lat_max+rincrement
or ISO_code+rincrement
. Here, we still need a string input.
That's a good point.
I don't think GMT's -R option has such syntax (see https://docs.generic-mapping-tools.org/dev/gmt.html#r-full).
This one should be supported currently. We probably should implement the ideas in #2646 and then people should use the proposed to
|
You are totally right; such a syntax is not available, and your guess is what I was actually thinking about. I must have gotten confused during writing - I apologize for the confusion! |
Description of proposed changes
In the previous version,
region
can be either a list or a string, but a string likeregion="0/10/0/20"
is not Pythonic and a tuple likeregion=(0, 10, 0, 20)
is also accepted.This PR adds type hints to the
region
parameter ofload_*
functions. Theregion
parameter must be aSequence
type (list, tuple, or array). A string type is still supported but no longer documented/recommended.Preview: https://pygmt-dev--3272.org.readthedocs.build/en/3272/api/generated/pygmt.datasets.load_earth_age.html#pygmt.datasets.load_earth_age