From f0dd9b005936519a4c02b136cb69ea985d7d237e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 4 Jan 2023 07:26:13 -0500 Subject: [PATCH 01/10] remove deprecated function for load_mars_shape --- pygmt/datasets/__init__.py | 1 - pygmt/datasets/samples.py | 28 +++------------------------- pygmt/tests/test_datasets_samples.py | 5 +---- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/pygmt/datasets/__init__.py b/pygmt/datasets/__init__.py index 87595e0b6bc..e5b62aacfef 100644 --- a/pygmt/datasets/__init__.py +++ b/pygmt/datasets/__init__.py @@ -15,7 +15,6 @@ load_fractures_compilation, load_hotspots, load_japan_quakes, - load_mars_shape, load_ocean_ridge_points, load_sample_bathymetry, load_sample_data, diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 52cc349a1c8..76b0e605b22 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -74,7 +74,6 @@ def load_sample_data(name): "fractures": load_fractures_compilation, "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, } @@ -83,6 +82,7 @@ def load_sample_data(name): load_func = { "rock_compositions": _load_rock_sample_compositions, "earth_relief_holes": _load_earth_relief_holes, + "mars_shape": _load_mars_shape, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, } @@ -324,37 +324,15 @@ def load_hotspots(**kwargs): return data -def load_mars_shape(**kwargs): +def _load_mars_shape(**kwargs): """ - (Deprecated) Load a table of data for the shape of Mars. - - .. warning:: Deprecated since v0.6.0. This function has been replaced with - ``load_sample_data(name="mars_shape")`` and will be removed in - v0.9.0. - - This is the ``@mars370d.txt`` dataset used in GMT examples, with data and - information from Smith, D. E., and M. T. Zuber (1996), The shape of Mars - and the topographic signature of the hemispheric dichotomy. Data columns - are "longitude," "latitude", and "radius (meters)." - - 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. + Load a table of data for the shape of Mars as a pandas.DataFrame. Returns ------- data : pandas.DataFrame The data table with columns "longitude", "latitude", and "radius(m)". """ - - 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='mars_shape') instead.", - category=FutureWarning, - stacklevel=2, - ) fname = which("@mars370d.txt", download="c") data = pd.read_csv( fname, sep="\t", header=None, names=["longitude", "latitude", "radius(m)"] diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 8fa1d8153ba..c1d86b2b281 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -8,7 +8,6 @@ load_fractures_compilation, load_hotspots, load_japan_quakes, - load_mars_shape, load_ocean_ridge_points, load_sample_bathymetry, load_sample_data, @@ -113,9 +112,7 @@ def test_mars_shape(): """ Check that the @mars370d.txt dataset loads without errors. """ - with pytest.warns(expected_warning=FutureWarning) as record: - data = load_mars_shape() - assert len(record) == 1 + data = load_sample_data(name="mars_shape") assert data.shape == (370, 3) assert data["longitude"].min() == 0.008 assert data["longitude"].max() == 359.983 From 46ca2a28f90865c4034e2ba412a358c4af18fa18 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 4 Jan 2023 07:31:21 -0500 Subject: [PATCH 02/10] remove load_mars_shape from api/index.rst --- doc/api/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index 618e95b6786..8333a2e7074 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -238,7 +238,6 @@ Use :func:`pygmt.datasets.load_sample_data` instead. datasets.load_fractures_compilation datasets.load_hotspots datasets.load_japan_quakes - datasets.load_mars_shape datasets.load_ocean_ridge_points datasets.load_sample_bathymetry datasets.load_usgs_quakes From b2c49985184864bb72e405a6647df67b3d4fac1e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 4 Jan 2023 07:39:22 -0500 Subject: [PATCH 03/10] remove "kwargs" from _load_mars_shape() --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 76b0e605b22..cb506d1825d 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -324,7 +324,7 @@ def load_hotspots(**kwargs): return data -def _load_mars_shape(**kwargs): +def _load_mars_shape(): """ Load a table of data for the shape of Mars as a pandas.DataFrame. From d738be9e5f680534191bec71a3e6d8b00d83087a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 6 Jan 2023 07:00:51 -0500 Subject: [PATCH 04/10] 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, 4 insertions(+) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index cb506d1825d..07d5f042f72 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -327,6 +327,10 @@ def load_hotspots(**kwargs): def _load_mars_shape(): """ Load a table of data for the shape of Mars as a pandas.DataFrame. + + Data and information are from Smith, D. E., and M. T. Zuber (1996), + The shape of Mars and the topographic signature of the hemispheric + dichotomy. Returns ------- From 5610ebdac934754955505d42e7612604adadff32 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 19 Jan 2023 18:38:04 -0500 Subject: [PATCH 05/10] Update pygmt/datasets/samples.py 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 07d5f042f72..95a07bb02db 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -335,7 +335,7 @@ def _load_mars_shape(): Returns ------- data : pandas.DataFrame - The data table with columns "longitude", "latitude", and "radius(m)". + The data table with column names "longitude", "latitude", and "radius_m". """ fname = which("@mars370d.txt", download="c") data = pd.read_csv( From ddab39fa66f5c6c64dc4444d1789057980d70a39 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 19 Jan 2023 18:42:26 -0500 Subject: [PATCH 06/10] change column header to radius_m --- pygmt/datasets/samples.py | 7 ++++--- pygmt/tests/test_datasets_samples.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 95a07bb02db..1b5db0de871 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -327,7 +327,7 @@ def load_hotspots(**kwargs): def _load_mars_shape(): """ Load a table of data for the shape of Mars as a pandas.DataFrame. - + Data and information are from Smith, D. E., and M. T. Zuber (1996), The shape of Mars and the topographic signature of the hemispheric dichotomy. @@ -335,11 +335,12 @@ def _load_mars_shape(): Returns ------- data : pandas.DataFrame - The data table with column names "longitude", "latitude", and "radius_m". + The data table with column names "longitude", "latitude", and + "radius_m". """ fname = which("@mars370d.txt", download="c") data = pd.read_csv( - fname, sep="\t", header=None, names=["longitude", "latitude", "radius(m)"] + fname, sep="\t", header=None, names=["longitude", "latitude", "radius_m"] ) return data diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index c1d86b2b281..a90979c2617 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -118,8 +118,8 @@ def test_mars_shape(): assert data["longitude"].max() == 359.983 assert data["latitude"].min() == -79.715 assert data["latitude"].max() == 85.887 - assert data["radius(m)"].min() == -6930 - assert data["radius(m)"].max() == 15001 + assert data["radius_m"].min() == -6930 + assert data["radius_m"].max() == 15001 def test_hotspots(): From 143886b3ca30c6d4231966b027e4ce0569587ad1 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 19 Jan 2023 18:45:01 -0500 Subject: [PATCH 07/10] run make format --- pygmt/datasets/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pygmt/datasets/__init__.py b/pygmt/datasets/__init__.py index 92cc2419ddf..332fbfccf82 100644 --- a/pygmt/datasets/__init__.py +++ b/pygmt/datasets/__init__.py @@ -10,8 +10,4 @@ from pygmt.datasets.earth_vertical_gravity_gradient import ( load_earth_vertical_gravity_gradient, ) -from pygmt.datasets.samples import ( - list_sample_data, - load_sample_data, - load_usgs_quakes, -) +from pygmt.datasets.samples import list_sample_data, load_sample_data, load_usgs_quakes From b77a364d7a985891d1f698c5011c62f22e8a356f Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 23 Jan 2023 08:11:38 -0500 Subject: [PATCH 08/10] remove load_func_old --- pygmt/datasets/samples.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index be2cb8dcd54..7d203d9fb23 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -1,8 +1,6 @@ """ Functions to load sample data. """ -import warnings - import pandas as pd from pygmt.exceptions import GMTInvalidInput from pygmt.io import load_dataarray @@ -68,9 +66,6 @@ def load_sample_data(name): if name not in names: raise GMTInvalidInput(f"Invalid dataset name '{name}'.") - # Dictionary of public load functions for backwards compatibility - load_func_old = {} - # Dictionary of private load functions load_func = { "bathymetry": _load_baja_california_bathymetry, @@ -86,9 +81,7 @@ def load_sample_data(name): "usgs_quakes": _load_usgs_quakes, } - if name in load_func_old: - data = load_func_old[name](suppress_warning=True) - elif name in load_func: + if name in load_func: data = load_func[name]() return data From 8e5ab24f8e463bb095e5c4417c5f45f122c819a4 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 24 Jan 2023 07:28:33 -0500 Subject: [PATCH 09/10] Update pygmt/datasets/samples.py Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 7d203d9fb23..982428ba986 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -70,10 +70,10 @@ def load_sample_data(name): load_func = { "bathymetry": _load_baja_california_bathymetry, "earth_relief_holes": _load_earth_relief_holes, - "mars_shape": _load_mars_shape, "fractures": _load_fractures_compilation, "hotspots": _load_hotspots, "japan_quakes": _load_japan_quakes, + "mars_shape": _load_mars_shape, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, "ocean_ridge_points": _load_ocean_ridge_points, From 4961cc42c700c624e26860a718c7f69787840b05 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 30 Jan 2023 13:06:58 -0500 Subject: [PATCH 10/10] remove unnecessary if statement --- pygmt/datasets/samples.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 982428ba986..15477e18358 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -80,11 +80,7 @@ def load_sample_data(name): "rock_compositions": _load_rock_sample_compositions, "usgs_quakes": _load_usgs_quakes, } - - if name in load_func: - data = load_func[name]() - - return data + return load_func[name]() def _load_japan_quakes():