Skip to content

Commit a3cb87b

Browse files
seismanweiji14
andauthored
Figure.wiggle: Reorder input parameter to 'data, x, y, z' (#1548)
Co-authored-by: Wei Ji <[email protected]>
1 parent e53c7ae commit a3cb87b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

pygmt/helpers/decorators.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,15 @@ def new_module(*args, **kwargs):
857857
New module instance that raises a warning if positional arguments
858858
are passed.
859859
"""
860-
if len(args) > 0: # positional arguments are used
860+
# Plotting functions always have a "self" parameter
861+
# which is a pygmt.Figure instance that has a "savefig" method
862+
if len(args) > 1 and hasattr(args[0], "savefig"):
863+
plotting_func = 1
864+
else:
865+
plotting_func = 0
866+
867+
if len(args) > 1 + plotting_func:
868+
# more than one positional arguments are used
861869
msg = (
862870
"The function parameters has been re-ordered as 'data, x, y, [z]' "
863871
f"since {deprecate_version} but you're passing positional arguments. "

pygmt/src/wiggle.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pygmt.clib import Session
55
from pygmt.helpers import (
66
build_arg_string,
7+
check_data_input_order,
78
deprecate_parameter,
89
fmt_docstring,
910
kwargs_to_strings,
@@ -13,6 +14,7 @@
1314

1415
@fmt_docstring
1516
@deprecate_parameter("columns", "incols", "v0.5.0", remove_version="v0.7.0")
17+
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
1618
@use_alias(
1719
B="frame",
1820
D="position",
@@ -39,7 +41,7 @@
3941
w="wrap",
4042
)
4143
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
42-
def wiggle(self, x=None, y=None, z=None, data=None, **kwargs):
44+
def wiggle(self, data=None, x=None, y=None, z=None, **kwargs):
4345
r"""
4446
Plot z=f(x,y) anomalies along tracks.
4547

pygmt/tests/test_wiggle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def test_wiggle_deprecate_columns_to_incols():
5050
fig = Figure()
5151
with pytest.warns(expected_warning=FutureWarning) as record:
5252
fig.wiggle(
53+
data,
5354
region=[-4, 4, -1, 1],
5455
projection="X8c",
55-
data=data,
5656
columns=[1, 0, 2],
5757
scale="0.5c",
5858
color=["red+p", "gray+n"],

0 commit comments

Comments
 (0)