Skip to content

Commit

Permalink
Split up functions for loading datasets (#1955)
Browse files Browse the repository at this point in the history
  • Loading branch information
willschlitzer authored Jun 14, 2022
1 parent 880b344 commit 2febc8f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,27 @@ def load_sample_data(name):
if name not in names:
raise GMTInvalidInput(f"Invalid dataset name '{name}'.")

load_func = {
# Dictionary of public load functions for backwards compatibility
load_func_old = {
"bathymetry": load_sample_bathymetry,
"earth_relief_holes": _load_earth_relief_holes,
"fractures": load_fractures_compilation,
"hotspots": load_hotspots,
"japan_quakes": load_japan_quakes,
"mars_shape": load_mars_shape,
"ocean_ridge_points": load_ocean_ridge_points,
"notre_dame_topography": _load_notre_dame_topography,
"usgs_quakes": load_usgs_quakes,
}

data = load_func[name](suppress_warning=True)
# Dictionary of private load functions
load_func = {
"earth_relief_holes": _load_earth_relief_holes,
"notre_dame_topography": _load_notre_dame_topography,
}

if name in load_func_old:
data = load_func_old[name](suppress_warning=True)
elif name in load_func:
data = load_func[name]()

return data

Expand Down Expand Up @@ -350,7 +358,7 @@ def load_mars_shape(**kwargs):
return data


def _load_notre_dame_topography(**kwargs): # pylint: disable=unused-argument
def _load_notre_dame_topography():
"""
Load Table 5.11 in Davis: Statistics and Data Analysis in Geology.
Expand All @@ -363,7 +371,7 @@ def _load_notre_dame_topography(**kwargs): # pylint: disable=unused-argument
return pd.read_csv(fname, sep=r"\s+", header=None, names=["x", "y", "z"])


def _load_earth_relief_holes(**kwargs): # pylint: disable=unused-argument
def _load_earth_relief_holes():
"""
Loads the remote file @earth_relief_20m_holes.grd.
Expand Down

0 comments on commit 2febc8f

Please sign in to comment.