diff --git a/doc/api/index.rst b/doc/api/index.rst index 448ca2c50ce..e0a5df6a097 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -235,7 +235,6 @@ Use :func:`pygmt.datasets.load_sample_data` instead. .. autosummary:: :toctree: generated - datasets.load_hotspots datasets.load_mars_shape datasets.load_usgs_quakes diff --git a/pygmt/datasets/__init__.py b/pygmt/datasets/__init__.py index 1a395f1e160..a16257bf308 100644 --- a/pygmt/datasets/__init__.py +++ b/pygmt/datasets/__init__.py @@ -12,7 +12,6 @@ ) from pygmt.datasets.samples import ( list_sample_data, - load_hotspots, load_mars_shape, load_sample_data, load_usgs_quakes, diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index c657dad9083..5fd54b8c006 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -70,7 +70,6 @@ def load_sample_data(name): # Dictionary of public load functions for backwards compatibility load_func_old = { - "hotspots": load_hotspots, "mars_shape": load_mars_shape, "usgs_quakes": load_usgs_quakes, } @@ -80,6 +79,7 @@ def load_sample_data(name): "bathymetry": _load_baja_california_bathymetry, "earth_relief_holes": _load_earth_relief_holes, "fractures": _load_fractures_compilation, + "hotspots": _load_hotspots, "japan_quakes": _load_japan_quakes, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, @@ -217,43 +217,29 @@ def _load_fractures_compilation(): return data[["length", "azimuth"]] -def load_hotspots(**kwargs): +def _load_hotspots(): """ - (Deprecated) Load a table with the locations, names, and suggested symbol - sizes of hotspots. + Load a table with the locations, names, and suggested symbol sizes of + hotspots as a pandas.DataFrame. - .. warning:: Deprecated since v0.6.0. This function has been replaced with - ``load_sample_data(name="hotspots")`` and will be removed in - v0.9.0. - - This is the ``@hotspots.txt`` dataset used in the GMT tutorials, with data - from Mueller, Royer, and Lawver, 1993, Geology, vol. 21, pp. 275-278. The - main 5 hotspots used by Doubrovine et al. [2012] have symbol sizes twice - the size of all other hotspots. - - The data are downloaded to a cache directory (usually ``~/.gmt/cache``) the - first time you invoke this function. Afterwards, it will load the data from - the cache. So you'll need an internet connection the first time around. + The data are from Mueller, Royer, and Lawver, 1993, Geology, vol. 21, + pp. 275-278. The main 5 hotspots used by Doubrovine et al. [2012] + have symbol sizes twice the size of all other hotspots. Returns ------- data : pandas.DataFrame - The data table with columns "longitude", "latitude", "symbol_size", and - "placename". + The data table. The column names are "longitude", "latitude", + "symbol_size", and "place_name". """ - if "suppress_warning" not in kwargs: - warnings.warn( - "This function has been deprecated since v0.6.0 and will be " - "removed in v0.9.0. Please use " - "load_sample_data(name='hotspots') instead.", - category=FutureWarning, - stacklevel=2, - ) fname = which("@hotspots.txt", download="c") - columns = ["longitude", "latitude", "symbol_size", "place_name"] - data = pd.read_table(filepath_or_buffer=fname, sep="\t", skiprows=3, names=columns) - return data + return pd.read_csv( + fname, + sep="\t", + skiprows=3, + names=["longitude", "latitude", "symbol_size", "place_name"], + ) def load_mars_shape(**kwargs): diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 9fa5bab3728..57c5ab9f2f5 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -4,12 +4,7 @@ import numpy.testing as npt import pandas as pd import pytest -from pygmt.datasets import ( - load_hotspots, - load_mars_shape, - load_sample_data, - load_usgs_quakes, -) +from pygmt.datasets import load_mars_shape, load_sample_data, load_usgs_quakes from pygmt.exceptions import GMTInvalidInput @@ -103,9 +98,7 @@ def test_hotspots(): """ Check that the @hotspots.txt dataset loads without errors. """ - with pytest.warns(expected_warning=FutureWarning) as record: - data = load_hotspots() - assert len(record) == 1 + data = load_sample_data(name="hotspots") assert data.shape == (55, 4) assert list(data.columns) == [ "longitude", @@ -114,6 +107,12 @@ def test_hotspots(): "place_name", ] assert isinstance(data, pd.DataFrame) + assert data["longitude"].min() == -169.6 + assert data["longitude"].max() == 167 + assert data["latitude"].min() == -78 + assert data["latitude"].max() == 64 + assert data["symbol_size"].min() == 0.25 + assert data["symbol_size"].max() == 0.5 def test_load_notre_dame_topography():