From 1024424efc65843665b3e4f77e57d612839d427a Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 25 Sep 2022 00:09:36 +0800 Subject: [PATCH 1/9] Remove timestamp (U) alias from all plotting methods --- pygmt/helpers/decorators.py | 11 +++++++++++ pygmt/src/basemap.py | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index dee33ba29f9..7963a4a4c9a 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -575,6 +575,17 @@ def new_module(*args, **kwargs): f"Use long-form parameter '{long_alias}' instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + + # timestamp (U) is deprecated since v0.8.0. + if "U" in kwargs or "timestamp" in kwargs: + if "timestamp" in kwargs: + kwargs["U"] = kwargs.pop("timestamp") + msg = ( + "Parameter 'U' and 'timestamp' is deprecated since v0.8.0. " + "Use Figure.timestamp() instead." + ) + warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + return module_func(*args, **kwargs) new_module.aliases = aliases diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index da7319a835c..74be3b3430a 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -23,7 +23,6 @@ F="box", Td="rose", Tm="compass", - U="timestamp", V="verbose", X="xshift", Y="yshift", @@ -82,7 +81,6 @@ def basemap(self, **kwargs): compass : str Draws a map magnetic rose on the map at the location defined by the reference and anchor points - {timestamp} {verbose} {xyshift} {panel} From 80a2ac4a91de4893a7fb67efc2284e45d45c92c3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 5 Nov 2022 10:25:14 +0800 Subject: [PATCH 2/9] Update pygmt/helpers/decorators.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/helpers/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 7963a4a4c9a..17dba91ed20 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -576,7 +576,7 @@ def new_module(*args, **kwargs): ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) - # timestamp (U) is deprecated since v0.8.0. + # timestamp (U) is deprecated since v0.8.0, remove in v0.12.0 if "U" in kwargs or "timestamp" in kwargs: if "timestamp" in kwargs: kwargs["U"] = kwargs.pop("timestamp") From 4f46fa931230699ad88e793b86b5174bbf8551e3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 5 Nov 2022 10:56:14 +0800 Subject: [PATCH 3/9] Update pygmt/helpers/decorators.py --- pygmt/helpers/decorators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 17dba91ed20..cd774ad4ca8 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -581,7 +581,8 @@ def new_module(*args, **kwargs): if "timestamp" in kwargs: kwargs["U"] = kwargs.pop("timestamp") msg = ( - "Parameter 'U' and 'timestamp' is deprecated since v0.8.0. " + "Parameters 'U' and 'timestamp' are deprecated since v0.8.0 " + "and will be removed in v0.12.0. " "Use Figure.timestamp() instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) From 41b7f34350df4edc21fe4249c01214b7b7eacd4c Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 29 Nov 2022 16:16:50 +0800 Subject: [PATCH 4/9] Fix a typo --- pygmt/helpers/decorators.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 652d21db86e..a18a7999596 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -577,6 +577,7 @@ def new_module(*args, **kwargs): "Parameters 'U' and 'timestamp' are deprecated since v0.8.0 " "and will be removed in v0.12.0. " "Use Figure.timestamp() instead." + ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) # xshift (X) is deprecated since v0.8.0. From d62dcd2cc896c9b3384f62decb102812668c8f5f Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 2 Mar 2023 14:24:57 +0800 Subject: [PATCH 5/9] Remove timestamps --- pygmt/helpers/decorators.py | 7 ++----- pygmt/src/coast.py | 2 -- pygmt/src/contour.py | 2 -- pygmt/src/grdcontour.py | 2 -- pygmt/src/grdimage.py | 1 - pygmt/src/histogram.py | 2 -- pygmt/src/image.py | 2 -- pygmt/src/legend.py | 2 -- pygmt/src/logo.py | 2 -- pygmt/src/plot.py | 2 -- pygmt/src/plot3d.py | 1 - pygmt/src/rose.py | 2 -- pygmt/src/solar.py | 2 -- pygmt/src/ternary.py | 2 -- pygmt/src/text.py | 2 -- pygmt/src/velo.py | 2 -- pygmt/src/wiggle.py | 2 -- 17 files changed, 2 insertions(+), 35 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 81c07469e78..adb1c6470e8 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -35,9 +35,6 @@ frame : bool or str or list Set map boundary :doc:`frame and axes attributes `. """, - "timestamp": r""" - timestamp : bool or str - Draw GMT time stamp logo on plot.""", "cmap": r""" cmap : str File name of a CPT file or a series of comma-separated colors @@ -565,12 +562,12 @@ def new_module(*args, **kwargs): ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) - # timestamp (U) is deprecated since v0.8.0. + # timestamp (U) is deprecated since v0.9.0. if "U" in kwargs or "timestamp" in kwargs: if "timestamp" in kwargs: kwargs["U"] = kwargs.pop("timestamp") msg = ( - "Parameters 'U' and 'timestamp' are deprecated since v0.8.0 " + "Parameters 'U' and 'timestamp' are deprecated since v0.9.0 " "and will be removed in v0.12.0. " "Use Figure.timestamp() instead." ) diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index 014c951eddc..c89a6a9aa71 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -30,7 +30,6 @@ W="shorelines", G="land", S="water", - U="timestamp", V="verbose", c="panel", p="perspective", @@ -147,7 +146,6 @@ def coast(self, **kwargs): a = All boundaries (1-3) water : str Select filling or clipping of "wet" areas. - {timestamp} shorelines : int or str or list [*level*\ /]\ *pen*. Draw shorelines [Default is no shorelines]. Append pen attributes diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index 00f1999deb1..8f0d4c59d00 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -17,7 +17,6 @@ N="no_clip", R="region", S="skip", - U="timestamp", V="verbose", W="pen", b="binary", @@ -102,7 +101,6 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs): to be of the format [*annotcontlabel*][/*contlabel*]. If either label contains a slash (/) character then use ``|`` as the separator for the two labels instead. - {timestamp} {verbose} {binary} {panel} diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 45689968f5b..68fa1b0be2f 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -18,7 +18,6 @@ Q="cut", R="region", S="resample", - U="timestamp", V="verbose", W="pen", l="label", @@ -80,7 +79,6 @@ def grdcontour(self, grid, **kwargs): Control the placement of labels along the quoted lines. It supports five controlling algorithms. See :gmt-docs:`grdcontour.html#g` for details. - {timestamp} {verbose} {pen} {panel} diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index 0b88e26088f..1640bfc65be 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -29,7 +29,6 @@ N="no_clip", Q="nan_transparent", R="region", - U="timestamp", V="verbose", n="interpolation", c="panel", diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 3167e688b3e..5cf8b4476fd 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -21,7 +21,6 @@ R="region", S="stairs", T="series", - U="timestamp", V="verbose", W="pen", Z="histtype", @@ -122,7 +121,6 @@ def histogram(self, data, **kwargs): To use weights provided as a second data column instead of pure counts, append **+w**. - {timestamp} {verbose} {binary} {nodata} diff --git a/pygmt/src/image.py b/pygmt/src/image.py index f6840deaac8..3852e02789f 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -12,7 +12,6 @@ D="position", F="box", M="monochrome", - U="timestamp", V="verbose", c="panel", p="perspective", @@ -53,7 +52,6 @@ def image(self, imagefile, **kwargs): monochrome : bool Convert color image to monochrome grayshades using the (television) YIQ-transformation. - {timestamp} {verbose} {panel} {perspective} diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index 1d4551f0b5e..ab195548c33 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -19,7 +19,6 @@ J="projection", D="position", F="box", - U="timestamp", V="verbose", c="panel", p="perspective", @@ -63,7 +62,6 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg using :gmt-term:`MAP_FRAME_PEN`. By default, uses **+g**\ white\ **+p**\ 1p which draws a box around the legend using a 1p black pen and adds a white background. - {timestamp} {verbose} {panel} {perspective} diff --git a/pygmt/src/logo.py b/pygmt/src/logo.py index e84e1bc83cb..8e4e0dd7fe6 100644 --- a/pygmt/src/logo.py +++ b/pygmt/src/logo.py @@ -13,7 +13,6 @@ D="position", F="box", S="style", - U="timestamp", V="verbose", c="panel", t="transparency", @@ -51,7 +50,6 @@ def logo(self, **kwargs): [Default] - **n** to skip the label placement - **u** to place the URL to the GMT site - {timestamp} {verbose} {panel} {transparency} diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index c3781c71316..b3fd5f85625 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -31,7 +31,6 @@ N="no_clip", R="region", S="style", - U="timestamp", V="verbose", W="pen", Z="zvalue", @@ -183,7 +182,6 @@ def plot(self, data=None, x=None, y=None, size=None, direction=None, **kwargs): Plot symbols (including vectors, pie slices, fronts, decorated or quoted lines). {pen} - {timestamp} {verbose} zvalue : str *value*\|\ *file*. diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index 2b7b57194fd..622084169b3 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -151,7 +151,6 @@ def plot3d( the foreground are plotted after items in the background. style : str Plot symbols. Full documentation is at :gmt-docs:`plot3d.html#s`. - {timestamp} {verbose} {pen} zvalue : str diff --git a/pygmt/src/rose.py b/pygmt/src/rose.py index 8a549bdd9ed..bd3c89aa9b5 100644 --- a/pygmt/src/rose.py +++ b/pygmt/src/rose.py @@ -30,7 +30,6 @@ R="region", S="norm", T="orientation", - U="timestamp", V="verbose", W="pen", Z="scale", @@ -188,7 +187,6 @@ def rose(self, data=None, length=None, azimuth=None, **kwargs): Statistics, *J. Stat. Software*, 31(10), 1-21, https://doi.org/10.18637/jss.v031.i10. - {timestamp} {verbose} {binary} {panel} diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 86aff53a35d..3be1374d7b2 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -15,7 +15,6 @@ G="fill", J="projection", R="region", - U="timestamp", V="verbose", W="pen", c="panel", @@ -56,7 +55,6 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs): Set color or pattern for filling terminators [Default is no fill]. pen : str Set pen attributes for lines [Default is ``"0.25p,black,solid"``]. - {timestamp} {verbose} {panel} {perspective} diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index 8c4b6d20366..08a24ae85a5 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -16,7 +16,6 @@ JX="width", R="region", S="style", - U="timestamp", V="verbose", W="pen", c="panel", @@ -69,7 +68,6 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs): *symbol*\[\ *size*]. Plot individual symbols in a ternary diagram. {pen} - {timestamp} {verbose} {panel} {perspective} diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 6c23778bb2c..1266204ef65 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -25,7 +25,6 @@ D="offset", G="fill", N="no_clip", - U="timestamp", V="verbose", W="pen", a="aspatial", @@ -148,7 +147,6 @@ def text_( (see ``clearance``) [Default is ``"0.25p,black,solid"``]. no_clip : bool Do NOT clip text at map boundaries [Default is with clip]. - {timestamp} {verbose} {aspatial} {panel} diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index ae4b1d7dfe3..a1be115d126 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -33,7 +33,6 @@ N="no_clip", R="region", S="spec", - U="timestamp", V="verbose", W="pen", Z="zvalue", @@ -216,7 +215,6 @@ def velo(self, data=None, **kwargs): no_clip: bool or str Do NOT skip symbols that fall outside the frame boundary specified by ``region`` [Default plots symbols inside frame only]. - {timestamp} {verbose} pen : str [*pen*][**+c**\ [**f**\|\ **l**]]. diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 8763cf7096b..2913c1d954b 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -16,7 +16,6 @@ J="projection", R="region", T="track", - U="timestamp", V="verbose", W="pen", Z="scale", @@ -86,7 +85,6 @@ def wiggle( track : str Draw track [Default is no track]. Append pen attributes to use [Default is ``"0.25p,black,solid"``]. - {timestamp} {verbose} pen : str Specify outline pen attributes [Default is no outline]. From 9604e2778bcf22b6bff9701eb1f230d25c18b15a Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 3 Mar 2023 13:57:23 +0800 Subject: [PATCH 6/9] Add a unit test to make sure that old syntax are still supported --- pygmt/tests/test_timestamp.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index 1c092a8918c..80c22e84da4 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -3,7 +3,7 @@ """ import pytest from packaging.version import Version -from pygmt import Figure, __gmt_version__ +from pygmt import Figure, __gmt_version__, config @pytest.fixture(scope="module", name="faketime") @@ -86,3 +86,31 @@ def test_timestamp_text(faketime): fig = Figure() fig.timestamp(text=faketime) return fig + + +@pytest.mark.mpl_image_compare(filename="test_timestamp.png") +def test_timestamp_deprecated_timestamp(faketime): + """ + Check if the deprecated parameter 'timestamp' works but raises a warning. + """ + fig = Figure() + with pytest.warns(expected_warning=SyntaxWarning) as record: + with config(FORMAT_TIME_STAMP=faketime): + # plot nothing (the data is outside the region) except a timestamp + fig.plot(x=0, y=0, projection="X1c", region=[1, 2, 1, 2], timestamp=True) + assert len(record) == 1 # check that only one warning was raised + return fig + + +@pytest.mark.mpl_image_compare(filename="test_timestamp.png") +def test_timestamp_deprecated_U(faketime): + """ + Check if the deprecated parameter 'U' works but raises a warning. + """ + fig = Figure() + with pytest.warns(expected_warning=SyntaxWarning) as record: + with config(FORMAT_TIME_STAMP=faketime): + # plot nothing (the data is outside the region) but a timestamp + fig.plot(x=0, y=0, projection="X1c", region=[1, 2, 1, 2], U=True) + assert len(record) == 1 # check that only one warning was raised + return fig From 87ded01d94810738aabdb759e70301d412ea0161 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 3 Mar 2023 14:00:44 +0800 Subject: [PATCH 7/9] Fix linting issue --- pygmt/tests/test_timestamp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index 80c22e84da4..e14b7708d44 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -103,7 +103,7 @@ def test_timestamp_deprecated_timestamp(faketime): @pytest.mark.mpl_image_compare(filename="test_timestamp.png") -def test_timestamp_deprecated_U(faketime): +def test_timestamp_deprecated_u(faketime): """ Check if the deprecated parameter 'U' works but raises a warning. """ From 373335437f7f68b10913f75e3f8a9b78011f0c8c Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 3 Mar 2023 14:03:32 +0800 Subject: [PATCH 8/9] Update pygmt/tests/test_timestamp.py --- pygmt/tests/test_timestamp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index e14b7708d44..e2fc295e819 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -96,7 +96,7 @@ def test_timestamp_deprecated_timestamp(faketime): fig = Figure() with pytest.warns(expected_warning=SyntaxWarning) as record: with config(FORMAT_TIME_STAMP=faketime): - # plot nothing (the data is outside the region) except a timestamp + # plot nothing (the data is outside the region) but a timestamp fig.plot(x=0, y=0, projection="X1c", region=[1, 2, 1, 2], timestamp=True) assert len(record) == 1 # check that only one warning was raised return fig From 942232678eb9bb6cd220468d56ce25aab9d5d180 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 3 Mar 2023 14:38:35 +0800 Subject: [PATCH 9/9] Fix the minor differences in image dimensions --- pygmt/tests/test_timestamp.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index e2fc295e819..93cad987cb5 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -97,7 +97,14 @@ def test_timestamp_deprecated_timestamp(faketime): with pytest.warns(expected_warning=SyntaxWarning) as record: with config(FORMAT_TIME_STAMP=faketime): # plot nothing (the data is outside the region) but a timestamp - fig.plot(x=0, y=0, projection="X1c", region=[1, 2, 1, 2], timestamp=True) + fig.plot( + x=0, + y=0, + style="p", + projection="X1c", + region=[1, 2, 1, 2], + timestamp=True, + ) assert len(record) == 1 # check that only one warning was raised return fig @@ -111,6 +118,6 @@ def test_timestamp_deprecated_u(faketime): with pytest.warns(expected_warning=SyntaxWarning) as record: with config(FORMAT_TIME_STAMP=faketime): # plot nothing (the data is outside the region) but a timestamp - fig.plot(x=0, y=0, projection="X1c", region=[1, 2, 1, 2], U=True) + fig.plot(x=0, y=0, style="p", projection="X1c", region=[1, 2, 1, 2], U=True) assert len(record) == 1 # check that only one warning was raised return fig