Skip to content

Commit 7d98e66

Browse files
authored
TYP: Add type hints support for pygmt.datasets.load_sample_data (#2859)
1 parent e3d59b2 commit 7d98e66

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

pygmt/datasets/samples.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Functions to load sample data.
33
"""
4-
from typing import Callable, NamedTuple
4+
from typing import Callable, Literal, NamedTuple
55

66
import pandas as pd
77
from pygmt.exceptions import GMTInvalidInput
@@ -70,7 +70,6 @@ def _load_baja_california_bathymetry():
7070
The data table. The column names are "longitude", "latitude",
7171
and "bathymetry".
7272
"""
73-
7473
fname = which("@tut_ship.xyz", download="c")
7574
return pd.read_csv(
7675
fname, sep="\t", header=None, names=["longitude", "latitude", "bathymetry"]
@@ -99,10 +98,9 @@ def _load_fractures_compilation():
9998
Returns
10099
-------
101100
data : pandas.DataFrame
102-
The data table. The column names are "length" and
103-
"azimuth" of the fractures.
101+
The data table. The column names are "length" and "azimuth" of
102+
the fractures.
104103
"""
105-
106104
fname = which("@fractures_06.txt", download="c")
107105
data = pd.read_csv(
108106
fname, header=None, delim_whitespace=True, names=["azimuth", "length"]
@@ -166,7 +164,6 @@ def _load_rock_sample_compositions():
166164
The data table with columns "limestone", "water", "air",
167165
and "permittivity".
168166
"""
169-
170167
fname = which("@ternary.txt", download="c")
171168
return pd.read_csv(
172169
fname,
@@ -300,7 +297,21 @@ def list_sample_data():
300297
return {name: dataset.description for name, dataset in datasets.items()}
301298

302299

303-
def load_sample_data(name):
300+
def load_sample_data(
301+
name: Literal[
302+
"bathymetry",
303+
"earth_relief_holes",
304+
"fractures",
305+
"hotspots",
306+
"japan_quakes",
307+
"mars_shape",
308+
"maunaloa_co2",
309+
"notre_dame_topography",
310+
"ocean_ridge_points",
311+
"rock_compositions",
312+
"usgs_quakes",
313+
],
314+
):
304315
"""
305316
Load an example dataset from the GMT server.
306317
@@ -310,7 +321,7 @@ def load_sample_data(name):
310321
311322
Parameters
312323
----------
313-
name : str
324+
name
314325
Name of the dataset to load.
315326
316327
Returns

0 commit comments

Comments
 (0)