pygmt.dataset.load_*: Add type hints for the 'region' parameter#3272
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.
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.
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,
regioncan 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
regionparameter ofload_*functions. Theregionparameter must be aSequencetype (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