From fc3c28dcc5ee671065d0f0dacb996330afe086c9 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:44:51 +0100 Subject: [PATCH 01/14] Update wiggle.py --- pygmt/src/wiggle.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 226fbe7c62a..1ecc74d4726 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -2,14 +2,15 @@ wiggle - Plot z=f(x,y) anomalies along tracks. """ from pygmt.clib import Session -from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias, deprecate_parameter @fmt_docstring +@deprecate_parameter("color", "fill", "v0.8.0", "v0.12.0") @use_alias( B="frame", D="position", - G="color", + G="fill", J="projection", R="region", T="track", @@ -65,12 +66,12 @@ def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): **+w**\ *length*\ [**+j**\ *justify*]\ [**+al**\|\ **r**]\ [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]]. Defines the reference point on the map for the vertical scale bar. - color : str + fill : str Set fill shade, color or pattern for positive and/or negative wiggles [Default is no fill]. Optionally, append **+p** to fill positive areas (this is the default behavior). Append **+n** to fill negative areas. Append **+n+p** to fill both positive and negative areas with the same - fill. **Note**: You will need to repeat the color parameter to select + fill. **Note**: You will need to repeat the fill parameter to select different fills for the positive and negative wiggles. track : str From 5ea432555ca60b5620cdb53471069bf4320633fa Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:51:06 +0000 Subject: [PATCH 02/14] [format-command] fixes --- pygmt/src/wiggle.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 1ecc74d4726..3882de4f4e7 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -2,7 +2,13 @@ wiggle - Plot z=f(x,y) anomalies along tracks. """ from pygmt.clib import Session -from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias, deprecate_parameter +from pygmt.helpers import ( + build_arg_string, + deprecate_parameter, + fmt_docstring, + kwargs_to_strings, + use_alias, +) @fmt_docstring From 8d95aa4c24d8354d75906f68fecbf2ebbc405ce8 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:20:34 +0100 Subject: [PATCH 03/14] add new parameters --- pygmt/helpers/decorators.py | 3 -- pygmt/helpers/testing.py | 2 -- pygmt/src/wiggle.py | 59 ++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 23 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 1af025e0d8e..f16b2310387 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/src/wiggle.py b/pygmt/src/wiggle.py index 3882de4f4e7..aa9989b0b85 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -1,22 +1,18 @@ """ wiggle - Plot z=f(x,y) anomalies along tracks. """ +import warnings + from pygmt.clib import Session -from pygmt.helpers import ( - build_arg_string, - deprecate_parameter, - fmt_docstring, - kwargs_to_strings, - use_alias, -) +from pygmt.exceptions import GMTInvalidInput +from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias @fmt_docstring -@deprecate_parameter("color", "fill", "v0.8.0", "v0.12.0") @use_alias( B="frame", D="position", - G="fill", + G="color", J="projection", R="region", T="track", @@ -37,7 +33,16 @@ w="wrap", ) @kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence") -def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): +def wiggle( + self, + data=None, + x=None, + y=None, + z=None, + fill_positive=None, + fill_negative=None, + **kwargs +): r""" Plot z=f(x,y) anomalies along tracks. @@ -72,14 +77,10 @@ def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): **+w**\ *length*\ [**+j**\ *justify*]\ [**+al**\|\ **r**]\ [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]]. Defines the reference point on the map for the vertical scale bar. - fill : str - Set fill shade, color or pattern for positive and/or negative wiggles - [Default is no fill]. Optionally, append **+p** to fill positive areas - (this is the default behavior). Append **+n** to fill negative areas. - Append **+n+p** to fill both positive and negative areas with the same - fill. **Note**: You will need to repeat the fill parameter to select - different fills for the positive and negative wiggles. - + fill_positive : str + Set fill shade, color or pattern for positive wiggles [Default is no fill]. + fill_negative : str + Set fill shade, color or pattern for negative wiggles [Default is no fill]. track : str Draw track [Default is no track]. Append pen attributes to use [Default is ``"0.25p,black,solid"``]. @@ -101,6 +102,28 @@ def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access + if kwargs.get("G") is not None: + msg = ( + "The 'color' parameter has been deprecated since v0.8.0" + " and will be removed in v0.12.0. Use fill_positive/fill_negative instead." + ) + warnings.warn(msg, category=FutureWarning, stacklevel=2) + + if (fill_positive or fill_negative) and kwargs.get("G") is not None: + raise GMTInvalidInput("Use either fill_positive/fill_negative or color.") + + if fill_positive: + if kwargs.get("G") is not None: + kwargs["G"] = [kwargs["G"], fill_positive + "+p"] + else: + kwargs["G"] = fill_positive + "+p" + + if fill_negative: + if kwargs.get("G") is not None: + kwargs["G"] = [kwargs["G"], fill_negative + "+n"] + else: + kwargs["G"] = fill_negative + "+n" + with Session() as lib: # Choose how data will be passed in to the module file_context = lib.virtualfile_from_data( From 30d4efe2035028b922f36512939fee969609e130 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:27:33 +0100 Subject: [PATCH 04/14] format --- pygmt/src/wiggle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 8570954ea3d..675e34fa810 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -105,7 +105,8 @@ def wiggle( if kwargs.get("G") is not None: msg = ( "The 'color' parameter has been deprecated since v0.8.0" - " and will be removed in v0.12.0. Use fill_positive/fill_negative instead." + " and will be removed in v0.12.0. Use fill_positive/fill_negative" + " instead." ) warnings.warn(msg, category=FutureWarning, stacklevel=2) From c03daaf9a438851fc4e1213b54215a789563f5ae Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:29:38 +0100 Subject: [PATCH 05/14] format --- pygmt/src/wiggle.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 675e34fa810..bc10e3ce283 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -78,9 +78,11 @@ def wiggle( [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]]. Defines the reference point on the map for the vertical scale bar. fill_positive : str - Set fill shade, color or pattern for positive wiggles [Default is no fill]. + Set fill shade, color or pattern for positive wiggles [Default is no + fill]. fill_negative : str - Set fill shade, color or pattern for negative wiggles [Default is no fill]. + Set fill shade, color or pattern for negative wiggles [Default is no + fill]. track : str Draw track [Default is no track]. Append pen attributes to use [Default is ``"0.25p,black,solid"``]. From fdd37da23a48e633568a1c72e6a05499bcf38607 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:32:14 +0100 Subject: [PATCH 06/14] adjust tests --- pygmt/tests/test_wiggle.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index 95bd052920e..d67e45e5814 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -23,7 +23,8 @@ def test_wiggle(): y=y, z=z, scale="0.5c", - color=["red+p", "gray+n"], + fill_positive="red", + fill_negative="gray", pen="1.0p", track="0.5p", position="jRM+w2+lnT", @@ -51,7 +52,8 @@ def test_wiggle_data_incols(): projection="X8c", incols=[1, 0, 2], scale="0.5c", - color=["red+p", "gray+n"], + fill_positive="red", + fill_negative="gray", pen="1.0p", track="0.5p", position="jRM+w2+lnT", From f99b6158d113edac72936188594c968e0e5c5d2d Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:35:27 +0100 Subject: [PATCH 07/14] adjust gallery example --- examples/gallery/lines/wiggle.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/gallery/lines/wiggle.py b/examples/gallery/lines/wiggle.py index 791e102e1ac..fb2359555b7 100644 --- a/examples/gallery/lines/wiggle.py +++ b/examples/gallery/lines/wiggle.py @@ -6,7 +6,8 @@ tracks. ``x``, ``y``, ``z`` can be specified as 1-D arrays or within a specified file. The ``scale`` parameter can be used to set the scale of the anomaly in data/distance units. The positive and/or negative areas can be -filled with color by setting the ``color`` parameter. +filled with color by setting the ``fill_positive`` and/or ``fill_negative`` +parameters. """ import numpy as np @@ -25,8 +26,10 @@ z=z, # Set anomaly scale to 20 centimeters scale="20c", - # Fill positive and negative areas red and gray, respectively - color=["red+p", "gray+n"], + # Fill positive areas red + fill_positive="red", + # Fill negative areas gray + fill_negative="gray", # Set the outline width to 1.0 point pen="1.0p", # Draw a blue track with a width of 0.5 points From bb7576f6c3fc3c6b0653f6b702d61a9a83773ad8 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 23 Dec 2022 16:41:31 +0100 Subject: [PATCH 08/14] format --- 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 8030c7f16d2..50788fdded1 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 429df1d4da0..06eb3af0482 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 903f506c3226f828557afa41d62547701a0e579c Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 24 Dec 2022 11:30:59 +0100 Subject: [PATCH 09/14] update --- pygmt/src/wiggle.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index bc10e3ce283..a410c7ef0b1 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -116,10 +116,7 @@ def wiggle( raise GMTInvalidInput("Use either fill_positive/fill_negative or color.") if fill_positive: - if kwargs.get("G") is not None: - kwargs["G"] = [kwargs["G"], fill_positive + "+p"] - else: - kwargs["G"] = fill_positive + "+p" + kwargs["G"] = fill_positive + "+p" if fill_negative: if kwargs.get("G") is not None: From 125ab57255ee295bccb57d085aad915d93df2274 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sat, 24 Dec 2022 11:49:04 +0100 Subject: [PATCH 10/14] add test --- pygmt/src/wiggle.py | 6 +++--- pygmt/tests/test_wiggle.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index a410c7ef0b1..7636283373f 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -104,6 +104,9 @@ def wiggle( """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access + if (fill_positive or fill_negative) and kwargs.get("G") is not None: + raise GMTInvalidInput("Use either fill_positive/fill_negative or color.") + if kwargs.get("G") is not None: msg = ( "The 'color' parameter has been deprecated since v0.8.0" @@ -112,9 +115,6 @@ def wiggle( ) warnings.warn(msg, category=FutureWarning, stacklevel=2) - if (fill_positive or fill_negative) and kwargs.get("G") is not None: - raise GMTInvalidInput("Use either fill_positive/fill_negative or color.") - if fill_positive: kwargs["G"] = fill_positive + "+p" diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index d67e45e5814..b3b4e3953ed 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -4,6 +4,7 @@ import numpy as np import pytest from pygmt import Figure +from pygmt.exceptions import GMTInvalidInput @pytest.mark.mpl_image_compare @@ -59,3 +60,31 @@ def test_wiggle_data_incols(): position="jRM+w2+lnT", ) return fig + + +def test_wiggle_fill_multiple(): + """ + Check that wiggle fails when the parameters color and + fill_positive/fill_negative are used together. + """ + x = np.arange(-2, 2, 0.02) + y = np.zeros(x.size) + z = np.cos(2 * np.pi * x) + + fig = Figure() + with pytest.raises(GMTInvalidInput): + fig.wiggle( + x=x, + y=y, + z=z, + region=[-4, 4, -1, 1], + projection="X8c", + incols=[1, 0, 2], + scale="0.5c", + color="blue", + fill_positive="red", + fill_negative="gray", + pen="1.0p", + track="0.5p", + position="jRM+w2+lnT", + ) From 0d245d0b439bcb42efd8e084f8ec49d66dd887af Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 25 Dec 2022 10:08:30 +0100 Subject: [PATCH 11/14] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/wiggle.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 7636283373f..738f763d9b5 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -115,14 +115,12 @@ def wiggle( ) warnings.warn(msg, category=FutureWarning, stacklevel=2) - if fill_positive: - kwargs["G"] = fill_positive + "+p" - - if fill_negative: - if kwargs.get("G") is not None: - kwargs["G"] = [kwargs["G"], fill_negative + "+n"] - else: - kwargs["G"] = fill_negative + "+n" + if fill_positive or fill_negative: + kwargs["G"] = [] + if fill_positive: + kwargs["G"].append(fill_positive + "+p") + if fill_negative: + kwargs["G"].append(fill_negative + "+n") with Session() as lib: # Choose how data will be passed in to the module From d8dcbf8cebf3acd41a715787d2505baaf3c574d5 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 25 Dec 2022 12:08:47 +0100 Subject: [PATCH 12/14] add color test --- pygmt/tests/test_wiggle.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index b3b4e3953ed..ff9039b8d32 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -88,3 +88,30 @@ def test_wiggle_fill_multiple(): track="0.5p", position="jRM+w2+lnT", ) + + +def test_wiggle_use_color(): + """ + Check that wiggle raises a warning when the deprecated parameter color is + used. + """ + x = np.arange(-2, 2, 0.02) + y = np.zeros(x.size) + z = np.cos(2 * np.pi * x) + + fig = Figure() + with pytest.warns(expected_warning=FutureWarning) as record: + fig.wiggle( + x=x, + y=y, + z=z, + region=[-4, 4, -1, 1], + projection="X8c", + incols=[1, 0, 2], + scale="0.5c", + color="blue", + pen="1.0p", + track="0.5p", + position="jRM+w2+lnT", + ) + assert len(record) == 1 From ee471a67a73345b5982f54f02129ae34e13f2b2e Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 25 Dec 2022 17:30:25 +0100 Subject: [PATCH 13/14] adjust parameter names --- examples/gallery/lines/wiggle.py | 6 +++--- pygmt/src/wiggle.py | 24 ++++++++++++------------ pygmt/tests/test_wiggle.py | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/gallery/lines/wiggle.py b/examples/gallery/lines/wiggle.py index fb2359555b7..75cc6fa98c9 100644 --- a/examples/gallery/lines/wiggle.py +++ b/examples/gallery/lines/wiggle.py @@ -6,7 +6,7 @@ tracks. ``x``, ``y``, ``z`` can be specified as 1-D arrays or within a specified file. The ``scale`` parameter can be used to set the scale of the anomaly in data/distance units. The positive and/or negative areas can be -filled with color by setting the ``fill_positive`` and/or ``fill_negative`` +filled with color by setting the ``fillpositive`` and/or ``fillnegative`` parameters. """ @@ -27,9 +27,9 @@ # Set anomaly scale to 20 centimeters scale="20c", # Fill positive areas red - fill_positive="red", + fillpositive="red", # Fill negative areas gray - fill_negative="gray", + fillnegative="gray", # Set the outline width to 1.0 point pen="1.0p", # Draw a blue track with a width of 0.5 points diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 738f763d9b5..6f3f808e083 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -39,8 +39,8 @@ def wiggle( x=None, y=None, z=None, - fill_positive=None, - fill_negative=None, + fillpositive=None, + fillnegative=None, **kwargs ): r""" @@ -77,10 +77,10 @@ def wiggle( **+w**\ *length*\ [**+j**\ *justify*]\ [**+al**\|\ **r**]\ [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]]. Defines the reference point on the map for the vertical scale bar. - fill_positive : str + fillpositive : str Set fill shade, color or pattern for positive wiggles [Default is no fill]. - fill_negative : str + fillnegative : str Set fill shade, color or pattern for negative wiggles [Default is no fill]. track : str @@ -104,23 +104,23 @@ def wiggle( """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access - if (fill_positive or fill_negative) and kwargs.get("G") is not None: - raise GMTInvalidInput("Use either fill_positive/fill_negative or color.") + if (fillpositive or fillnegative) and kwargs.get("G") is not None: + raise GMTInvalidInput("Use either fillpositive/fillnegative or color.") if kwargs.get("G") is not None: msg = ( "The 'color' parameter has been deprecated since v0.8.0" - " and will be removed in v0.12.0. Use fill_positive/fill_negative" + " and will be removed in v0.12.0. Use fillpositive/fillnegative" " instead." ) warnings.warn(msg, category=FutureWarning, stacklevel=2) - if fill_positive or fill_negative: + if fillpositive or fillnegative: kwargs["G"] = [] - if fill_positive: - kwargs["G"].append(fill_positive + "+p") - if fill_negative: - kwargs["G"].append(fill_negative + "+n") + if fillpositive: + kwargs["G"].append(fillpositive + "+p") + if fillnegative: + kwargs["G"].append(fillnegative + "+n") with Session() as lib: # Choose how data will be passed in to the module diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index ff9039b8d32..261315e0f9c 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -24,8 +24,8 @@ def test_wiggle(): y=y, z=z, scale="0.5c", - fill_positive="red", - fill_negative="gray", + fillpositive="red", + fillnegative="gray", pen="1.0p", track="0.5p", position="jRM+w2+lnT", @@ -53,8 +53,8 @@ def test_wiggle_data_incols(): projection="X8c", incols=[1, 0, 2], scale="0.5c", - fill_positive="red", - fill_negative="gray", + fillpositive="red", + fillnegative="gray", pen="1.0p", track="0.5p", position="jRM+w2+lnT", @@ -65,7 +65,7 @@ def test_wiggle_data_incols(): def test_wiggle_fill_multiple(): """ Check that wiggle fails when the parameters color and - fill_positive/fill_negative are used together. + fillpositive/fillnegative are used together. """ x = np.arange(-2, 2, 0.02) y = np.zeros(x.size) @@ -82,8 +82,8 @@ def test_wiggle_fill_multiple(): incols=[1, 0, 2], scale="0.5c", color="blue", - fill_positive="red", - fill_negative="gray", + fillpositive="red", + fillnegative="gray", pen="1.0p", track="0.5p", position="jRM+w2+lnT", From c89d614b88fbfadfe2ca434385cb98c7eeb765cc Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 26 Dec 2022 11:44:33 +0100 Subject: [PATCH 14/14] 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/src/wiggle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index 6f3f808e083..e2b9d09a902 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -78,10 +78,10 @@ def wiggle( [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]]. Defines the reference point on the map for the vertical scale bar. fillpositive : str - Set fill shade, color or pattern for positive wiggles [Default is no + Set fill shade, color, or pattern for positive wiggles [Default is no fill]. fillnegative : str - Set fill shade, color or pattern for negative wiggles [Default is no + Set fill shade, color, or pattern for negative wiggles [Default is no fill]. track : str Draw track [Default is no track]. Append pen attributes to use