Skip to content

Commit 14082d8

Browse files
authored
pygmt.dataset.load_*: Add type hints for the 'region' parameter (#3272)
1 parent 466c8b6 commit 14082d8

12 files changed

+73
-108
lines changed

pygmt/datasets/earth_age.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_earth_age"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_earth_age(
1817
resolution: Literal[
1918
"01d", "30m", "20m", "15m", "10m", "06m", "05m", "04m", "03m", "02m", "01m"
2019
] = "01d",
21-
region=None,
20+
region: Sequence[float] | str | None = None,
2221
registration: Literal["gridline", "pixel"] = "gridline",
2322
):
2423
r"""
@@ -56,13 +55,10 @@ def load_earth_age(
5655
resolution
5756
The grid resolution. The suffix ``d`` and ``m`` stand for arc-degrees and
5857
arc-minutes.
59-
60-
region : str or list
61-
The subregion of the grid to load, in the form of a list
62-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
63-
Required for grids with resolutions higher than 5
64-
arc-minutes (i.e., ``"05m"``).
65-
58+
region
59+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
60+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
61+
higher than 5 arc-minutes (i.e., ``"05m"``).
6662
registration
6763
Grid registration type. Either ``"pixel"`` for pixel registration or
6864
``"gridline"`` for gridline registration.

pygmt/datasets/earth_free_air_anomaly.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_earth_free_air_anomaly"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_earth_free_air_anomaly(
1817
resolution: Literal[
1918
"01d", "30m", "20m", "15m", "10m", "06m", "05m", "04m", "03m", "02m", "01m"
2019
] = "01d",
21-
region=None,
20+
region: Sequence[float] | str | None = None,
2221
registration: Literal["gridline", "pixel", None] = None,
2322
):
2423
r"""
@@ -56,13 +55,10 @@ def load_earth_free_air_anomaly(
5655
resolution
5756
The grid resolution. The suffix ``d`` and ``m`` stand for arc-degrees and
5857
arc-minutes.
59-
60-
region : str or list
61-
The subregion of the grid to load, in the form of a list
62-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
63-
Required for grids with resolutions higher than 5
64-
arc-minutes (i.e., ``"05m"``).
65-
58+
region
59+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
60+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
61+
higher than 5 arc-minutes (i.e., ``"05m"``).
6662
registration
6763
Grid registration type. Either ``"pixel"`` for pixel registration or
6864
``"gridline"`` for gridline registration. Default is ``None``, means

pygmt/datasets/earth_geoid.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_earth_geoid"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_earth_geoid(
1817
resolution: Literal[
1918
"01d", "30m", "20m", "15m", "10m", "06m", "05m", "04m", "03m", "02m", "01m"
2019
] = "01d",
21-
region=None,
20+
region: Sequence[float] | str | None = None,
2221
registration: Literal["gridline", "pixel"] = "gridline",
2322
):
2423
r"""
@@ -49,13 +48,10 @@ def load_earth_geoid(
4948
resolution
5049
The grid resolution. The suffix ``d`` and ``m`` stand for arc-degrees and
5150
arc-minutes.
52-
53-
region : str or list
54-
The subregion of the grid to load, in the form of a list
55-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
56-
Required for grids with resolutions higher than 5
57-
arc-minutes (i.e., ``"05m"``).
58-
51+
region
52+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
53+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
54+
higher than 5 arc-minutes (i.e., ``"05m"``).
5955
registration
6056
Grid registration type. Either ``"pixel"`` for pixel registration or
6157
``"gridline"`` for gridline registration.

pygmt/datasets/earth_magnetic_anomaly.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1112
from pygmt.exceptions import GMTInvalidInput
12-
from pygmt.helpers import kwargs_to_strings
1313

1414
__doctest_skip__ = ["load_earth_magnetic_anomaly"]
1515

1616

17-
@kwargs_to_strings(region="sequence")
1817
def load_earth_magnetic_anomaly(
1918
resolution: Literal[
2019
"01d", "30m", "20m", "15m", "10m", "06m", "05m", "04m", "03m", "02m"
2120
] = "01d",
22-
region=None,
21+
region: Sequence[float] | str | None = None,
2322
registration: Literal["gridline", "pixel", None] = None,
2423
data_source: Literal["emag2", "emag2_4km", "wdmam"] = "emag2",
2524
):
@@ -70,20 +69,16 @@ def load_earth_magnetic_anomaly(
7069
The grid resolution. The suffix ``d`` and ``m`` stand for arc-degrees and
7170
arc-minutes. The resolution ``"02m"`` is not available for
7271
``data_source="wdmam"``.
73-
74-
region : str or list
75-
The subregion of the grid to load, in the form of a list
76-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
77-
Required for grids with resolutions higher than 5
78-
arc-minutes (i.e., ``"05m"``).
79-
72+
region
73+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
74+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
75+
higher than 5 arc-minutes (i.e., ``"05m"``).
8076
registration
8177
Grid registration type. Either ``"pixel"`` for pixel registration or
8278
``"gridline"`` for gridline registration. Default is ``None``, means
8379
``"gridline"`` for all resolutions except ``"02m"`` for
8480
``data_source="emag2"`` or ``data_source="emag2_4km"``, which are
8581
``"pixel"`` only.
86-
8782
data_source
8883
Select the source of the magnetic anomaly data. Available options are:
8984

pygmt/datasets/earth_mask.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_earth_mask"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_earth_mask(
1817
resolution: Literal[
1918
"01d",
@@ -30,7 +29,7 @@ def load_earth_mask(
3029
"30s",
3130
"15s",
3231
] = "01d",
33-
region=None,
32+
region: Sequence[float] | str | None = None,
3433
registration: Literal["gridline", "pixel"] = "gridline",
3534
):
3635
r"""
@@ -61,11 +60,9 @@ def load_earth_mask(
6160
resolution
6261
The grid resolution. The suffix ``d``, ``m``, and ``s`` stand for arc-degrees,
6362
arc-minutes, and arc-seconds.
64-
65-
region : str or list
66-
The subregion of the grid to load, in the form of a list
67-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
68-
63+
region
64+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
65+
*ymin*, *ymax*] or an ISO country code.
6966
registration
7067
Grid registration type. Either ``"pixel"`` for pixel registration or
7168
``"gridline"`` for gridline registration.

pygmt/datasets/earth_relief.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1112
from pygmt.exceptions import GMTInvalidInput
12-
from pygmt.helpers import kwargs_to_strings
1313

1414
__doctest_skip__ = ["load_earth_relief"]
1515

1616

17-
@kwargs_to_strings(region="sequence")
1817
def load_earth_relief(
1918
resolution: Literal[
2019
"01d",
@@ -33,10 +32,10 @@ def load_earth_relief(
3332
"03s",
3433
"01s",
3534
] = "01d",
36-
region=None,
35+
region: Sequence[float] | str | None = None,
3736
registration: Literal["gridline", "pixel", None] = None,
3837
data_source: Literal["igpp", "gebco", "gebcosi", "synbath"] = "igpp",
39-
use_srtm=False,
38+
use_srtm: bool = False,
4039
):
4140
r"""
4241
Load the Earth relief datasets (topography and bathymetry) in various resolutions.
@@ -77,19 +76,15 @@ def load_earth_relief(
7776
resolution
7877
The grid resolution. The suffix ``d``, ``m`` and ``s`` stand for arc-degrees,
7978
arc-minutes, and arc-seconds.
80-
81-
region : str or list
82-
The subregion of the grid to load, in the form of a list
83-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
84-
Required for Earth relief grids with resolutions higher than 5
85-
arc-minutes (i.e., ``"05m"``).
86-
79+
region
80+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
81+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
82+
higher than 5 arc-minutes (i.e., ``"05m"``).
8783
registration
8884
Grid registration type. Either ``"pixel"`` for pixel registration or
8985
``"gridline"`` for gridline registration. Default is ``None``, means
9086
``"gridline"`` for all resolutions except ``"15s"`` which is
9187
``"pixel"`` only.
92-
9388
data_source
9489
Select the source for the Earth relief data. Available options are:
9590
@@ -102,8 +97,7 @@ def load_earth_relief(
10297
inferred relief via altimetric gravity. See
10398
:gmt-datasets:`earth-gebco.html`.
10499
- ``"gebcosi"``: GEBCO Earth Relief that gives sub-ice (si) elevations.
105-
106-
use_srtm : bool
100+
use_srtm
107101
By default, the land-only SRTM tiles from NASA are used to generate the
108102
``"03s"`` and ``"01s"`` grids, and the missing ocean values are filled
109103
by up-sampling the SRTM15 tiles which have a resolution of 15

pygmt/datasets/earth_vertical_gravity_gradient.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_earth_vertical_gravity_gradient"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_earth_vertical_gravity_gradient(
1817
resolution: Literal[
1918
"01d", "30m", "20m", "15m", "10m", "06m", "05m", "04m", "03m", "02m", "01m"
2019
] = "01d",
21-
region=None,
20+
region: Sequence[float] | str | None = None,
2221
registration: Literal["gridline", "pixel", None] = None,
2322
):
2423
r"""
@@ -56,13 +55,10 @@ def load_earth_vertical_gravity_gradient(
5655
resolution
5756
The grid resolution. The suffix ``d`` and ``m`` stand for arc-degrees and
5857
arc-minutes.
59-
60-
region : str or list
61-
The subregion of the grid to load, in the form of a list
62-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*.
63-
Required for grids with resolutions higher than 5
64-
arc-minutes (i.e., ``"05m"``).
65-
58+
region
59+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
60+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
61+
higher than 5 arc-minutes (i.e., ``"05m"``).
6662
registration
6763
Grid registration type. Either ``"pixel"`` for pixel registration or
6864
``"gridline"`` for gridline registration. Default is ``None``, means

pygmt/datasets/mars_relief.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
The grids are available in various resolutions.
66
"""
77

8+
from collections.abc import Sequence
89
from typing import Literal
910

1011
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
11-
from pygmt.helpers import kwargs_to_strings
1212

1313
__doctest_skip__ = ["load_mars_relief"]
1414

1515

16-
@kwargs_to_strings(region="sequence")
1716
def load_mars_relief(
1817
resolution: Literal[
1918
"01d",
@@ -31,7 +30,7 @@ def load_mars_relief(
3130
"15s",
3231
"12s",
3332
] = "01d",
34-
region=None,
33+
region: Sequence[float] | str | None = None,
3534
registration: Literal["gridline", "pixel", None] = None,
3635
):
3736
r"""
@@ -68,10 +67,10 @@ def load_mars_relief(
6867
resolution
6968
The grid resolution. The suffix ``d``, ``m`` and ``s`` stand for arc-degrees,
7069
arc-minutes and arc-seconds.
71-
region : str or list
72-
The subregion of the grid to load, in the form of a list
73-
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*. Required for
74-
grids with resolutions higher than 5 arc-minutes (i.e., ``"05m"``).
70+
region
71+
The subregion of the grid to load, in the form of a sequence [*xmin*, *xmax*,
72+
*ymin*, *ymax*] or an ISO country code. Required for grids with resolutions
73+
higher than 5 arc-minutes (i.e., ``"05m"``).
7574
registration
7675
Grid registration type. Either ``"pixel"`` for pixel registration or
7776
``"gridline"`` for gridline registration. Default is ``None``, means

0 commit comments

Comments
 (0)