From c3be91ab0ebe3778417932372cb95a5709f0777d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 4 Jan 2023 08:21:40 -0500 Subject: [PATCH 1/3] replace "load_ocean_ridge_points" with "_load_ocean_ridge_points" --- doc/api/index.rst | 1 - pygmt/datasets/__init__.py | 1 - pygmt/datasets/samples.py | 32 ++++++++-------------------- pygmt/tests/test_datasets_samples.py | 5 +---- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index 618e95b6786..1902818f078 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -239,7 +239,6 @@ Use :func:`pygmt.datasets.load_sample_data` instead. datasets.load_hotspots datasets.load_japan_quakes datasets.load_mars_shape - datasets.load_ocean_ridge_points datasets.load_sample_bathymetry datasets.load_usgs_quakes diff --git a/pygmt/datasets/__init__.py b/pygmt/datasets/__init__.py index 87595e0b6bc..8209a8cf995 100644 --- a/pygmt/datasets/__init__.py +++ b/pygmt/datasets/__init__.py @@ -16,7 +16,6 @@ load_hotspots, load_japan_quakes, load_mars_shape, - load_ocean_ridge_points, load_sample_bathymetry, load_sample_data, load_usgs_quakes, diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 52cc349a1c8..0694b167c74 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -75,7 +75,6 @@ def load_sample_data(name): "hotspots": load_hotspots, "japan_quakes": load_japan_quakes, "mars_shape": load_mars_shape, - "ocean_ridge_points": load_ocean_ridge_points, "usgs_quakes": load_usgs_quakes, } @@ -85,6 +84,7 @@ def load_sample_data(name): "earth_relief_holes": _load_earth_relief_holes, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, + "ocean_ridge_points": _load_ocean_ridge_points, } if name in load_func_old: @@ -142,39 +142,25 @@ def load_japan_quakes(**kwargs): return data -def load_ocean_ridge_points(**kwargs): +def _load_ocean_ridge_points(): """ - (Deprecated) Load a table of ocean ridge points for the entire world as a + Load a table of ocean ridge points for the entire world as a pandas.DataFrame. - .. warning:: Deprecated since v0.6.0. This function has been replaced with - ``load_sample_data(name="ocean_ridge_points")`` and will be removed in - v0.9.0. - This is the ``@ridge.txt`` dataset used in the GMT tutorials. - 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. - Returns ------- data : pandas.DataFrame - The data table. Columns are longitude and latitude. + The data table. The column names are longitude and latitude. """ - - 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='ocean_ridge_points') " - "instead.", - category=FutureWarning, - stacklevel=2, - ) - fname = which("@ridge.txt", download="c") data = pd.read_csv( - fname, sep=r"\s+", names=["longitude", "latitude"], skiprows=1, comment=">" + fname, + delim_whitespace=True, + names=["longitude", "latitude"], + skiprows=1, + comment=">", ) return data diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 8fa1d8153ba..27e758558a7 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -9,7 +9,6 @@ load_hotspots, load_japan_quakes, load_mars_shape, - load_ocean_ridge_points, load_sample_bathymetry, load_sample_data, load_usgs_quakes, @@ -59,9 +58,7 @@ def test_ocean_ridge_points(): """ Check that the @ridge.txt dataset loads without errors. """ - with pytest.warns(expected_warning=FutureWarning) as record: - data = load_ocean_ridge_points() - assert len(record) == 1 + data = load_sample_data(name="ocean_ridge_points") assert data.shape == (4146, 2) assert data["longitude"].min() == -179.9401 assert data["longitude"].max() == 179.935 From 15478bf4f92092bab73589b3c12c5dd527860269 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 6 Jan 2023 07:05:25 -0500 Subject: [PATCH 2/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/datasets/samples.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 0694b167c74..2caf399432f 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -147,12 +147,10 @@ def _load_ocean_ridge_points(): Load a table of ocean ridge points for the entire world as a pandas.DataFrame. - This is the ``@ridge.txt`` dataset used in the GMT tutorials. - Returns ------- data : pandas.DataFrame - The data table. The column names are longitude and latitude. + The data table. The column names are "longitude" and "latitude". """ fname = which("@ridge.txt", download="c") data = pd.read_csv( From 057c53b5dda29b0e95bcbd535154f00982ba99cc Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 13 Jan 2023 12:07:10 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/datasets/samples.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 7ec74042dea..fcc478b0aa3 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -136,14 +136,13 @@ def _load_ocean_ridge_points(): The data table. The column names are "longitude" and "latitude". """ fname = which("@ridge.txt", download="c") - data = pd.read_csv( + return pd.read_csv( fname, delim_whitespace=True, names=["longitude", "latitude"], skiprows=1, comment=">", ) - return data def load_sample_bathymetry(**kwargs):