From 1b612e85290da6c871d1020ecd791f71dd449cca Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sat, 20 Aug 2022 18:14:18 +0200 Subject: [PATCH 01/26] Update legend.py --- pygmt/src/legend.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index 5e414992720..358eb86f772 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -21,8 +21,6 @@ F="box", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -67,7 +65,6 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg 1p black pen and adds a white background. {U} {V} - {XY} {c} {p} {t} From 0b101416f6384b205d5e6a127da69689adff0e05 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 20 Aug 2022 18:33:56 +0200 Subject: [PATCH 02/26] update --- pygmt/src/basemap.py | 3 --- pygmt/src/coast.py | 3 --- pygmt/src/colorbar.py | 3 --- pygmt/src/contour.py | 3 --- pygmt/src/grdcontour.py | 3 --- pygmt/src/grdimage.py | 3 --- pygmt/src/grdview.py | 3 --- pygmt/src/histogram.py | 3 --- pygmt/src/image.py | 3 --- 9 files changed, 27 deletions(-) diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index b3ad1f9095b..b739d769838 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -25,8 +25,6 @@ Tm="compass", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", f="coltypes", p="perspective", @@ -84,7 +82,6 @@ def basemap(self, **kwargs): reference and anchor points {U} {V} - {XY} {c} {f} {p} diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index 0b2773aa416..ed5a2df566d 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -30,8 +30,6 @@ S="water", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -176,7 +174,6 @@ def coast(self, **kwargs): (default is no fill). Append **+l**\|\ **+L** to =\ *continent* to only list countries in that continent; repeat if more than one continent is requested. - {XY} {c} {p} {t} diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 12f77219e03..1fc3323017b 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -18,8 +18,6 @@ I="shading", W="scale", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -100,7 +98,6 @@ def colorbar(self, **kwargs): asymmetric intensity range from *low* to *high*. [Default is no illumination]. {V} - {XY} {c} {p} {t} diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index b8085023346..e12ecf735fe 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -20,8 +20,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", b="binary", c="panel", d="nodata", @@ -106,7 +104,6 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs): separator for the two labels instead. {U} {V} - {XY} {b} {c} {d} diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index c1e5b53a164..0f2508e42c5 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -20,8 +20,6 @@ V="verbose", W="pen", l="label", - X="xshift", - Y="yshift", c="panel", f="coltypes", p="perspective", @@ -83,7 +81,6 @@ def grdcontour(self, grid, **kwargs): {U} {V} {W} - {XY} {c} {f} label : str diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index 8447f133e36..b2d8a70ef0a 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -29,8 +29,6 @@ R="region", U="timestamp", V="verbose", - X="xshift", - Y="yshift", n="interpolation", c="panel", f="coltypes", @@ -153,7 +151,6 @@ def grdimage(self, grid, **kwargs): 3). {R} {V} - {XY} {c} {f} {n} diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 43ad4a2af49..2de48a05bb1 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -30,8 +30,6 @@ Wf="facadepen", I="shading", V="verbose", - X="xshift", - Y="yshift", c="panel", f="coltypes", n="interpolation", @@ -114,7 +112,6 @@ def grdview(self, grid, **kwargs): **+d** to select the default arguments [Default is **+a**\ -45\ **+nt**\ 1\ **+m**\ 0]. {V} - {XY} {c} {f} {n} diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 84e872ca774..cd29eb6abed 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -24,8 +24,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="histtype", b="binary", c="panel", @@ -124,7 +122,6 @@ def histogram(self, data, **kwargs): To use weights provided as a second data column instead of pure counts, append **+w**. - {XY} {U} {V} {b} diff --git a/pygmt/src/image.py b/pygmt/src/image.py index c09ad939f59..1a84dafce0d 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -14,8 +14,6 @@ M="monochrome", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -57,7 +55,6 @@ def image(self, imagefile, **kwargs): YIQ-transformation. {U} {V} - {XY} {c} {p} {t} From 172714fc10a902081575ab0eeb24c9737331dd32 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 20 Aug 2022 18:42:09 +0200 Subject: [PATCH 03/26] update remaining functions --- pygmt/src/logo.py | 3 --- pygmt/src/meca.py | 3 --- pygmt/src/plot.py | 3 --- pygmt/src/plot3d.py | 3 --- pygmt/src/rose.py | 3 --- pygmt/src/solar.py | 3 --- pygmt/src/subplot.py | 5 +---- pygmt/src/text.py | 3 --- pygmt/src/velo.py | 3 --- pygmt/src/wiggle.py | 3 --- 10 files changed, 1 insertion(+), 31 deletions(-) diff --git a/pygmt/src/logo.py b/pygmt/src/logo.py index 45be41194da..57dd43840bd 100644 --- a/pygmt/src/logo.py +++ b/pygmt/src/logo.py @@ -15,8 +15,6 @@ S="style", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", t="transparency", ) @@ -55,7 +53,6 @@ def logo(self, **kwargs): - **u** to place the URL to the GMT site {U} {V} - {XY} {c} {t} """ diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index a44758f4037..5b1d22ef7df 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -81,8 +81,6 @@ def data_format_code(convention, component="full"): B="frame", N="no_clip", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -219,7 +217,6 @@ def meca( {R} {B} {V} - {XY} {c} {p} {t} diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index 566c8bb5412..f79e09af423 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -32,8 +32,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", a="aspatial", b="binary", @@ -184,7 +182,6 @@ def plot(self, data=None, x=None, y=None, size=None, direction=None, **kwargs): {W} {U} {V} - {XY} zvalue : str *value*\|\ *file*. Instead of specifying a symbol or polygon fill and outline color diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index cd20812de9a..526e41f04db 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -32,8 +32,6 @@ S="style", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", a="aspatial", b="binary", @@ -154,7 +152,6 @@ def plot3d( {U} {V} {W} - {XY} zvalue : str *value*\|\ *file*. Instead of specifying a symbol or polygon fill and outline color diff --git a/pygmt/src/rose.py b/pygmt/src/rose.py index f3df4bd60ea..81ea8ed6d89 100644 --- a/pygmt/src/rose.py +++ b/pygmt/src/rose.py @@ -26,8 +26,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="scale", b="binary", d="nodata", @@ -183,7 +181,6 @@ def rose(self, data=None, length=None, azimuth=None, **kwargs): {U} {V} - {XY} {b} {c} {d} diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index acbb5cba29c..7cdcef8bce2 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -16,8 +16,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -59,7 +57,6 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs): is ``default,black,solid``. {U} {V} - {XY} {c} {p} {t} diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index b7fd7f7a4c4..6599a74f0f5 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -28,9 +28,7 @@ SC="sharex", SR="sharey", T="title", - V="verbose", - X="xshift", - Y="yshift", + V="verbose" ) @kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence", R="sequence") def subplot(self, nrows=1, ncols=1, **kwargs): @@ -145,7 +143,6 @@ def subplot(self, nrows=1, ncols=1, **kwargs): ``frame``), the entire figure may also have an overarching *heading* [no heading]. Font is determined by setting :gmt-term:`FONT_HEADING`. {V} - {XY} """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 2cde7480d19..49cfbb91765 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -26,8 +26,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", a="aspatial", c="panel", e="find", @@ -150,7 +148,6 @@ def text_( Do NOT clip text at map boundaries [Default is will clip]. {U} {V} - {XY} {a} {c} {e} diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index 8cebd2e68f3..fc55a5d1fbb 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -26,8 +26,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", c="panel", d="nodata", @@ -218,7 +216,6 @@ def velo(self, data=None, **kwargs): updated from the CPT (see ``cmap``). If instead modifier **+cf** is appended then the color from the cpt file is applied to symbol fill only [Default]. Use just **+c** to set both pen and fill color. - {XY} zvalue : str [**m**\|\ **e**\|\ **n**\|\ **u**\ ][**+e**]. Select the quantity that will be used with the CPT given via ``cmap`` diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index d9c62d4349b..4631d530fb0 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -16,8 +16,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="scale", b="binary", c="panel", @@ -82,7 +80,6 @@ def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): {V} pen : str Specify outline pen attributes [Default is no outline]. - {XY} {b} {c} {d} From e22c16c72ebbfdc2b24fec097f0de63e869a5d21 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 20 Aug 2022 19:01:32 +0200 Subject: [PATCH 04/26] add exemplary error message --- pygmt/src/basemap.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index b739d769838..05ae92ce899 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -3,6 +3,7 @@ """ from pygmt.clib import Session +from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( args_in_kwargs, build_arg_string, @@ -90,5 +91,11 @@ def basemap(self, **kwargs): kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs): kwargs["B"] = True # Plotting frames if required arguments not given + if args_in_kwargs(args=["X", "Y"], kwargs=kwargs): + raise GMTInvalidInput( + """The parameters xshift (X) and yshift (Y) are not supported + anymore. Please use shift_origin() instead.""" + ) + with Session() as lib: lib.call_module(module="basemap", args=build_arg_string(kwargs)) From fb53e50d4f22373637ea985c4f85057815afb6f9 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 20 Aug 2022 19:07:23 +0200 Subject: [PATCH 05/26] format --- pygmt/src/subplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 6599a74f0f5..6743fd58b88 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -28,7 +28,7 @@ SC="sharex", SR="sharey", T="title", - V="verbose" + V="verbose", ) @kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence", R="sequence") def subplot(self, nrows=1, ncols=1, **kwargs): From 3d4934cc4e376643a3ade4b512f285988a1e9441 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 21 Aug 2022 11:23:46 +0200 Subject: [PATCH 06/26] remove xshift in 3d scatter plot example --- examples/gallery/3d_plots/scatter3d.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/gallery/3d_plots/scatter3d.py b/examples/gallery/3d_plots/scatter3d.py index 69d0716ab0e..f5a106a36ec 100644 --- a/examples/gallery/3d_plots/scatter3d.py +++ b/examples/gallery/3d_plots/scatter3d.py @@ -90,7 +90,9 @@ zscale=1.5, ) +# Shift plot origin in x direction +fig.shift_origin(xshift=3.1) # Add colorbar legend -fig.colorbar(xshift=3.1) +fig.colorbar() fig.show() From e5364b890f9be305cba74a2e7e76a73f0efa9746 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 21 Aug 2022 11:38:41 +0200 Subject: [PATCH 07/26] remove XY from common options --- pygmt/helpers/decorators.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index b67f7b69d62..aded93414c8 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -93,15 +93,6 @@ "W": """\ pen : str Set pen attributes for lines or the outline of symbols.""", - "XY": r""" - xshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*]. - Shift plot origin in x-direction. - yshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*]. - Shift plot origin in y-direction. Full documentation is at - :gmt-docs:`gmt.html#xy-full`. - """, "a": r""" aspatial : bool or str [*col*\ =]\ *name*\ [,...]. From e1df24d6321f1a2009cc3ff2dbcf532b0e4d56dd Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 21 Aug 2022 12:44:55 +0200 Subject: [PATCH 08/26] update decorator --- pygmt/helpers/decorators.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index aded93414c8..6066896019c 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -565,6 +565,14 @@ def new_module(*args, **kwargs): f"Parameters in short-form ({short_param}) and " f"long-form ({long_alias}) can't coexist." ) + if (long_alias in kwargs and long_alias in ["xshift", "yshift"]) or ( + short_param in kwargs and short_param in ["X", "Y"] + ): + raise GMTInvalidInput( + f"Parameters ({short_param}) and " + f"({long_alias}) are not supported anymore." + f" Please use shift_origin() instead!" + ) if long_alias in kwargs: kwargs[short_param] = kwargs.pop(long_alias) elif short_param in kwargs: From 3505b6b14963aacd85b2e0dc7fe21051c78a4a1e Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 21 Aug 2022 16:50:11 +0200 Subject: [PATCH 09/26] update --- pygmt/src/basemap.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index 05ae92ce899..b739d769838 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -3,7 +3,6 @@ """ from pygmt.clib import Session -from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( args_in_kwargs, build_arg_string, @@ -91,11 +90,5 @@ def basemap(self, **kwargs): kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs): kwargs["B"] = True # Plotting frames if required arguments not given - if args_in_kwargs(args=["X", "Y"], kwargs=kwargs): - raise GMTInvalidInput( - """The parameters xshift (X) and yshift (Y) are not supported - anymore. Please use shift_origin() instead.""" - ) - with Session() as lib: lib.call_module(module="basemap", args=build_arg_string(kwargs)) From 5e76789552a0c2d6467931c204057f18d7c46e11 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 29 Aug 2022 19:52:58 +0200 Subject: [PATCH 10/26] update if clause --- pygmt/helpers/decorators.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 6066896019c..2a207aec3f0 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -12,7 +12,7 @@ import numpy as np from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers.utils import is_nonstr_iter +from pygmt.helpers.utils import args_in_kwargs, is_nonstr_iter COMMON_OPTIONS = { "R": r""" @@ -93,6 +93,15 @@ "W": """\ pen : str Set pen attributes for lines or the outline of symbols.""", + "XY": r""" + xshift : str + [**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*]. + Shift plot origin in x-direction. + yshift : str + [**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*]. + Shift plot origin in y-direction. Full documentation is at + :gmt-docs:`gmt.html#xy-full`. + """, "a": r""" aspatial : bool or str [*col*\ =]\ *name*\ [,...]. @@ -565,14 +574,14 @@ def new_module(*args, **kwargs): f"Parameters in short-form ({short_param}) and " f"long-form ({long_alias}) can't coexist." ) - if (long_alias in kwargs and long_alias in ["xshift", "yshift"]) or ( - short_param in kwargs and short_param in ["X", "Y"] - ): + + if args_in_kwargs(args=["X", "Y"], kwargs=kwargs): raise GMTInvalidInput( - f"Parameters ({short_param}) and " - f"({long_alias}) are not supported anymore." + f"Parameters xshift, yshift, X and Y" + f" are not supported anymore." f" Please use shift_origin() instead!" ) + if long_alias in kwargs: kwargs[short_param] = kwargs.pop(long_alias) elif short_param in kwargs: From 25e097afff3253e3c129e3b31c6be44e83d95b85 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 29 Aug 2022 20:00:09 +0200 Subject: [PATCH 11/26] format --- pygmt/helpers/decorators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 2a207aec3f0..fd33cb2afbe 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -577,9 +577,9 @@ def new_module(*args, **kwargs): if args_in_kwargs(args=["X", "Y"], kwargs=kwargs): raise GMTInvalidInput( - f"Parameters xshift, yshift, X and Y" - f" are not supported anymore." - f" Please use shift_origin() instead!" + """Parameters xshift, yshift, X and Y are not + supported anymore Please use shift_origin() + instead!""" ) if long_alias in kwargs: From 444071da86f6e36a94908dbf15eea8d9a782212f Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 25 Sep 2022 14:33:47 +0200 Subject: [PATCH 12/26] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/solar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 18a38d4bf3d..32865185ee4 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -54,7 +54,7 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs): Color or pattern for filling of terminators. pen : str Set pen attributes for lines. The default pen - is ``default,black,solid``. + is ``"0.25p,black,solid"``. {timestamp} {verbose} {panel} From 94dc0ae9324ee5616a557eeecec86cc557178357 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 25 Sep 2022 14:46:00 +0200 Subject: [PATCH 13/26] add updates based on timestamp/U adjustments --- pygmt/helpers/decorators.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 0c4d96b15eb..dd9f385f821 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -567,14 +567,6 @@ def new_module(*args, **kwargs): f"Parameters in short-form ({short_param}) and " f"long-form ({long_alias}) can't coexist." ) - - if args_in_kwargs(args=["X", "Y"], kwargs=kwargs): - raise GMTInvalidInput( - """Parameters xshift, yshift, X and Y are not - supported anymore Please use shift_origin() - instead!""" - ) - if long_alias in kwargs: kwargs[short_param] = kwargs.pop(long_alias) elif short_param in kwargs: @@ -583,6 +575,27 @@ def new_module(*args, **kwargs): f"Use long-form parameter '{long_alias}' instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + + # xshift (X) is deprecated since v0.8.0. + if "X" in kwargs or "xshift" in kwargs: + if "xshift" in kwargs: + kwargs["X"] = kwargs.pop("xshift") + msg = ( + "Parameters 'X' and 'xshift' are deprecated since v0.8.0. " + "Use Figure.shift_origin(xshift=...) instead." + ) + warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + + # yshift (Y) is deprecated since v0.8.0. + if "Y" in kwargs or "yshift" in kwargs: + if "yshift" in kwargs: + kwargs["Y"] = kwargs.pop("yshift") + msg = ( + "Parameters 'Y' and 'yshift' are deprecated since v0.8.0. " + "Use Figure.shift_origin(yshift=...) instead." + ) + warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + return module_func(*args, **kwargs) new_module.aliases = aliases From acb01fe1d32bdd1dfe52c1a795f2a9d582a1000b Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 25 Sep 2022 14:48:46 +0200 Subject: [PATCH 14/26] format --- 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 dd9f385f821..5ef18e901c7 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -12,7 +12,7 @@ import numpy as np from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers.utils import args_in_kwargs, is_nonstr_iter +from pygmt.helpers.utils import is_nonstr_iter COMMON_DOCSTRINGS = { "region": r""" From a11ea8b0dc1847d757a72b193cbf4aff188a2a82 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 9 Nov 2022 08:53:56 +0100 Subject: [PATCH 15/26] Apply suggestions from code review Co-authored-by: Dongdong Tian --- 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 71c5a6c1a1c..c14562989a3 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -581,7 +581,8 @@ def new_module(*args, **kwargs): if "xshift" in kwargs: kwargs["X"] = kwargs.pop("xshift") msg = ( - "Parameters 'X' and 'xshift' are deprecated since v0.8.0. " + "Parameters 'X' and 'xshift' are deprecated since v0.8.0 " + "and will be removed in v0.12.0. " "Use Figure.shift_origin(xshift=...) instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) From 31823e398ac15a4089805e1fe779c5a0cc7f6f48 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:23:11 +0100 Subject: [PATCH 16/26] Update decorators.py --- pygmt/helpers/decorators.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index e36860484a5..3b9b7d6706d 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -595,6 +595,7 @@ def new_module(*args, **kwargs): kwargs["Y"] = kwargs.pop("yshift") msg = ( "Parameters 'Y' and 'yshift' are deprecated since v0.8.0. " + "and will be removed in v0.12.0. " "Use Figure.shift_origin(yshift=...) instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) From 8d62dddaba9f69131f4d4c1024d81c2b62e9eb4a Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 11 Nov 2022 13:53:12 +0100 Subject: [PATCH 17/26] Update ternary.py --- pygmt/src/ternary.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index b357289fe4c..297f0b99a6d 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -16,8 +16,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -66,7 +64,6 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs): *symbol*\[\ *size*]. Plot individual symbols in a ternary diagram. {pen} - {xyshift} {timestamp} {verbose} {panel} From 0f6f626284794fcdf3d9f349d91e209b6b66d833 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 11 Nov 2022 13:54:36 +0100 Subject: [PATCH 18/26] Update decorators.py --- pygmt/helpers/decorators.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 3b9b7d6706d..5d5cbcc2344 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -97,15 +97,6 @@ "pen": """\ pen : str Set pen attributes for lines or the outline of symbols.""", - "xyshift": r""" - xshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*]. - Shift plot origin in x-direction. - yshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*]. - Shift plot origin in y-direction. Full documentation is at - :gmt-docs:`gmt.html#xy-full`. - """, "aspatial": r""" aspatial : bool or str [*col*\ =]\ *name*\ [,...]. From bd2b05f2334a2f3dd0f1423a1a8d1721625b7696 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 11 Nov 2022 14:02:08 +0100 Subject: [PATCH 19/26] Update test_config.py --- pygmt/tests/test_config.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index 234f28431bf..3c6539ffebb 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -18,18 +18,18 @@ def test_config(): ) with config(FONT_LABEL="red", FONT_ANNOT_PRIMARY="red"): + fig.shift_origin(xshift="7c") fig.basemap( region=[0, 10, 0, 10], projection="X5c/5c", frame=["xaf+lred label", "yaf", "+tred annotation"], - xshift="7c", ) - + + fig.shift_origin(xshift="7c") fig.basemap( region=[0, 10, 0, 10], projection="X5c/5c", frame=["af", "+tBlue Annotation"], - xshift="7c", ) # Revert to default settings in current figure config(FONT_ANNOT_PRIMARY="black") @@ -131,7 +131,8 @@ def test_config_map_grid_cross_size(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -149,7 +150,8 @@ def test_config_map_grid_pen(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -167,7 +169,8 @@ def test_config_map_tick_length(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -185,5 +188,6 @@ def test_config_map_tick_pen(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig From a167be3a6299d4f5832099a77ea649d5fd0265d5 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Fri, 11 Nov 2022 13:04:37 +0000 Subject: [PATCH 20/26] [format-command] fixes --- pygmt/tests/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index 3c6539ffebb..a1e591e8220 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -24,7 +24,7 @@ def test_config(): projection="X5c/5c", frame=["xaf+lred label", "yaf", "+tred annotation"], ) - + fig.shift_origin(xshift="7c") fig.basemap( region=[0, 10, 0, 10], From 27d0a70629858398b0fa88b038d18249734bb198 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Wed, 16 Nov 2022 19:21:00 +0100 Subject: [PATCH 21/26] add tests --- pygmt/helpers/decorators.py | 3 --- pygmt/helpers/testing.py | 2 -- pygmt/tests/test_figure.py | 44 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 751adf6aa02..f62ca8e06ef 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -416,7 +416,6 @@ def fmt_docstring(module_func): ... {aliases} ... ''' ... pass - ... >>> print(gmtinfo.__doc__) My nice module. @@ -526,7 +525,6 @@ def use_alias(**aliases): >>> @use_alias(R="region", J="projection") ... def my_module(**kwargs): ... print("R =", kwargs["R"], "J =", kwargs["J"]) - ... >>> my_module(R="bla", J="meh") R = bla J = meh >>> my_module(region="bla", J="meh") @@ -767,7 +765,6 @@ def deprecate_parameter(oldname, newname, deprecate_version, remove_version): ... def module(data, size=0, **kwargs): ... "A module that prints the arguments it received" ... print(f"data={data}, size={size}, color={kwargs['color']}") - ... >>> # new names are supported >>> module(data="table.txt", size=5.0, color="red") data=table.txt, size=5.0, color=red diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 386d3bc7ad7..e610191f588 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -47,7 +47,6 @@ def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_imag ... projection="X5c", region=[0, 5, 0, 5], frame=["WrStZ", "af"] ... ) ... return fig_ref, fig_test - ... >>> test_check_figures_equal() >>> assert len(os.listdir("tmp_result_images")) == 0 >>> shutil.rmtree(path="tmp_result_images") # cleanup folder if tests pass @@ -59,7 +58,6 @@ def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_imag ... fig_test = Figure() ... fig_test.basemap(projection="X5c", region=[0, 3, 0, 3], frame=True) ... return fig_ref, fig_test - ... >>> with pytest.raises(GMTImageComparisonFailure): ... test_check_figures_unequal() ... diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 900c70d74ad..49a13d15030 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -274,3 +274,47 @@ def test_figure_icc_gray(): with pytest.warns(expected_warning=FutureWarning) as record: fig.psconvert(icc_gray=True, prefix="Test") assert len(record) == 1 # check that only one warning was raised + + +def test_figure_depr_xshift(): + """ + Check if deprecation of xshift parameter works correctly if used. + """ + fig = pygmt.Figure() + fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", xshift="3c") + assert len(record) == 1 # check that only one warning was raised + + +def test_figure_depr_X(): + """ + Check if deprecation of X parameter works correctly if used. + """ + fig = pygmt.Figure() + fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", X="3c") + assert len(record) == 1 # check that only one warning was raised + + +def test_figure_depr_yshift(): + """ + Check if deprecation of yshift parameter works correctly if used. + """ + fig = pygmt.Figure() + fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", yshift="3c") + assert len(record) == 1 # check that only one warning was raised + + +def test_figure_depr_Y(): + """ + Check if deprecation of Y parameter works correctly if used. + """ + fig = pygmt.Figure() + fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", Y="3c") + assert len(record) == 1 # check that only one warning was raised From 256abfdbc19ef79d048882c8e195ab0fa6177c0f Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 16 Nov 2022 19:58:59 +0100 Subject: [PATCH 22/26] Update test_figure.py --- pygmt/tests/test_figure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 49a13d15030..df10ae36c9b 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -280,7 +280,7 @@ def test_figure_depr_xshift(): """ Check if deprecation of xshift parameter works correctly if used. """ - fig = pygmt.Figure() + fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", xshift="3c") @@ -291,7 +291,7 @@ def test_figure_depr_X(): """ Check if deprecation of X parameter works correctly if used. """ - fig = pygmt.Figure() + fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", X="3c") @@ -302,7 +302,7 @@ def test_figure_depr_yshift(): """ Check if deprecation of yshift parameter works correctly if used. """ - fig = pygmt.Figure() + fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", yshift="3c") @@ -313,7 +313,7 @@ def test_figure_depr_Y(): """ Check if deprecation of Y parameter works correctly if used. """ - fig = pygmt.Figure() + fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", Y="3c") From e80797ccb5155430ce4adf9a8b5901c8449244d5 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Wed, 16 Nov 2022 19:05:54 +0000 Subject: [PATCH 23/26] [format-command] fixes --- pygmt/helpers/decorators.py | 3 +++ pygmt/helpers/testing.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index f62ca8e06ef..751adf6aa02 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -416,6 +416,7 @@ def fmt_docstring(module_func): ... {aliases} ... ''' ... pass + ... >>> print(gmtinfo.__doc__) My nice module. @@ -525,6 +526,7 @@ def use_alias(**aliases): >>> @use_alias(R="region", J="projection") ... def my_module(**kwargs): ... print("R =", kwargs["R"], "J =", kwargs["J"]) + ... >>> my_module(R="bla", J="meh") R = bla J = meh >>> my_module(region="bla", J="meh") @@ -765,6 +767,7 @@ def deprecate_parameter(oldname, newname, deprecate_version, remove_version): ... def module(data, size=0, **kwargs): ... "A module that prints the arguments it received" ... print(f"data={data}, size={size}, color={kwargs['color']}") + ... >>> # new names are supported >>> module(data="table.txt", size=5.0, color="red") data=table.txt, size=5.0, color=red diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index e610191f588..386d3bc7ad7 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -47,6 +47,7 @@ def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_imag ... projection="X5c", region=[0, 5, 0, 5], frame=["WrStZ", "af"] ... ) ... return fig_ref, fig_test + ... >>> test_check_figures_equal() >>> assert len(os.listdir("tmp_result_images")) == 0 >>> shutil.rmtree(path="tmp_result_images") # cleanup folder if tests pass @@ -58,6 +59,7 @@ def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_imag ... fig_test = Figure() ... fig_test.basemap(projection="X5c", region=[0, 3, 0, 3], frame=True) ... return fig_ref, fig_test + ... >>> with pytest.raises(GMTImageComparisonFailure): ... test_check_figures_unequal() ... From 4ead19459df7b1dced3e80ec0cbaf3432bb7c884 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 16 Nov 2022 20:21:49 +0100 Subject: [PATCH 24/26] Update test_figure.py --- pygmt/tests/test_figure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index df10ae36c9b..983b8c906df 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -287,7 +287,7 @@ def test_figure_depr_xshift(): assert len(record) == 1 # check that only one warning was raised -def test_figure_depr_X(): +def test_figure_depr_x(): """ Check if deprecation of X parameter works correctly if used. """ @@ -309,7 +309,7 @@ def test_figure_depr_yshift(): assert len(record) == 1 # check that only one warning was raised -def test_figure_depr_Y(): +def test_figure_depr_y(): """ Check if deprecation of Y parameter works correctly if used. """ From ea0e7304813fde2697b016a419c7b8808a7f7c40 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sat, 19 Nov 2022 10:57:22 +0100 Subject: [PATCH 25/26] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/tests/test_figure.py | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 983b8c906df..4e4d243a5d0 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -276,45 +276,21 @@ def test_figure_icc_gray(): assert len(record) == 1 # check that only one warning was raised -def test_figure_depr_xshift(): +def test_figure_deprecated_xshift_yshift(): """ - Check if deprecation of xshift parameter works correctly if used. + Check if deprecation of parameters X/Y/xshift/yshift work correctly if used. """ fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", xshift="3c") assert len(record) == 1 # check that only one warning was raised - - -def test_figure_depr_x(): - """ - Check if deprecation of X parameter works correctly if used. - """ - fig = Figure() - fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", X="3c") assert len(record) == 1 # check that only one warning was raised - - -def test_figure_depr_yshift(): - """ - Check if deprecation of yshift parameter works correctly if used. - """ - fig = Figure() - fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", yshift="3c") assert len(record) == 1 # check that only one warning was raised - - -def test_figure_depr_y(): - """ - Check if deprecation of Y parameter works correctly if used. - """ - fig = Figure() - fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=SyntaxWarning) as record: fig.plot(x=1, y=1, style="c3c", Y="3c") assert len(record) == 1 # check that only one warning was raised From 3e76319a66fa5d5cc3689582c4d94c670e3da589 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Sat, 19 Nov 2022 14:54:45 +0000 Subject: [PATCH 26/26] [format-command] fixes --- pygmt/tests/test_figure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 4e4d243a5d0..6f316780955 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -278,7 +278,8 @@ def test_figure_icc_gray(): def test_figure_deprecated_xshift_yshift(): """ - Check if deprecation of parameters X/Y/xshift/yshift work correctly if used. + Check if deprecation of parameters X/Y/xshift/yshift work correctly if + used. """ fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True)