Skip to content

Commit 5750390

Browse files
seismanJosh Sixsmith
authored and
Josh Sixsmith
committed
blockm/contour/plot/plot3d/rose/surface/wiggle: Change the parameter order of data array and input arrays (GenericMappingTools#1978)
1 parent 824e215 commit 5750390

File tree

9 files changed

+3
-103
lines changed

9 files changed

+3
-103
lines changed

pygmt/helpers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Functions, classes, decorators, and context managers to help wrap GMT modules.
33
"""
44
from pygmt.helpers.decorators import (
5-
check_data_input_order,
65
deprecate_parameter,
76
fmt_docstring,
87
kwargs_to_strings,

pygmt/helpers/decorators.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -806,71 +806,3 @@ def new_module(*args, **kwargs):
806806
return new_module
807807

808808
return deprecator
809-
810-
811-
def check_data_input_order(deprecate_version, remove_version):
812-
"""
813-
Decorator to raise a FutureWarning if the order of data input parameters
814-
changes and positional arguments are passed.
815-
816-
The decorator is temporary and should be removed in v0.7.0.
817-
818-
Parameters
819-
----------
820-
deprecate_version : str
821-
The PyGMT version when the order of data input parameters is changed.
822-
remove_version : str
823-
The PyGMT version when the deprecation warning should be removed.
824-
825-
Examples
826-
--------
827-
>>> @check_data_input_order("v0.0.0", "v9.9.9")
828-
... def module(data=None, x=None, y=None, z=None, **kwargs):
829-
... "A module that prints the arguments it received"
830-
... print(f"data={data}, x={x}, y={y}, z={z}")
831-
>>> module(data="table.txt")
832-
data=table.txt, x=None, y=None, z=None
833-
>>> module(x=0, y=1, z=2)
834-
data=None, x=0, y=1, z=2
835-
>>> with warnings.catch_warnings(record=True) as w:
836-
... module(0, 1, 2)
837-
... assert len(w) == 1
838-
... assert issubclass(w[0].category, FutureWarning)
839-
...
840-
data=0, x=1, y=2, z=None
841-
"""
842-
843-
def data_input_order_checker(module_func):
844-
"""
845-
The decorator that creates the new function to check if positional
846-
arguments are passed.
847-
"""
848-
849-
@functools.wraps(module_func)
850-
def new_module(*args, **kwargs):
851-
"""
852-
New module instance that raises a warning if positional arguments
853-
are passed.
854-
"""
855-
# Plotting functions always have a "self" parameter
856-
# which is a pygmt.Figure instance that has a "savefig" method
857-
if len(args) > 1 and hasattr(args[0], "savefig"):
858-
plotting_func = 1
859-
else:
860-
plotting_func = 0
861-
862-
if len(args) > 1 + plotting_func:
863-
# more than one positional arguments are used
864-
msg = (
865-
"The function parameters has been re-ordered as 'data, x, y, [z]' "
866-
f"since {deprecate_version} but you're passing positional arguments. "
867-
"You can silence the warning by passing keyword arguments "
868-
"like 'x=x, y=y, z=z'. Otherwise, the warning will be removed "
869-
f"in {remove_version}."
870-
)
871-
warnings.warn(msg, category=FutureWarning, stacklevel=2)
872-
return module_func(*args, **kwargs)
873-
874-
return new_module
875-
876-
return data_input_order_checker

pygmt/src/blockm.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pygmt.helpers import (
77
GMTTempFile,
88
build_arg_string,
9-
check_data_input_order,
109
fmt_docstring,
1110
kwargs_to_strings,
1211
use_alias,
@@ -70,7 +69,6 @@ def _blockm(block_method, data, x, y, z, outfile, **kwargs):
7069

7170

7271
@fmt_docstring
73-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
7472
@use_alias(
7573
I="spacing",
7674
R="region",
@@ -168,7 +166,6 @@ def blockmean(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
168166

169167

170168
@fmt_docstring
171-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
172169
@use_alias(
173170
I="spacing",
174171
R="region",
@@ -256,7 +253,6 @@ def blockmedian(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
256253

257254

258255
@fmt_docstring
259-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
260256
@use_alias(
261257
I="spacing",
262258
R="region",

pygmt/src/contour.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
"""
44

55
from pygmt.clib import Session
6-
from pygmt.helpers import (
7-
build_arg_string,
8-
check_data_input_order,
9-
fmt_docstring,
10-
kwargs_to_strings,
11-
use_alias,
12-
)
6+
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
137

148

159
@fmt_docstring
16-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
1710
@use_alias(
1811
A="annotation",
1912
B="frame",

pygmt/src/plot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pygmt.exceptions import GMTInvalidInput
66
from pygmt.helpers import (
77
build_arg_string,
8-
check_data_input_order,
98
data_kind,
109
fmt_docstring,
1110
is_nonstr_iter,
@@ -16,7 +15,6 @@
1615

1716

1817
@fmt_docstring
19-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
2018
@use_alias(
2119
A="straight_line",
2220
B="frame",

pygmt/src/plot3d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pygmt.exceptions import GMTInvalidInput
66
from pygmt.helpers import (
77
build_arg_string,
8-
check_data_input_order,
98
data_kind,
109
fmt_docstring,
1110
is_nonstr_iter,
@@ -16,7 +15,6 @@
1615

1716

1817
@fmt_docstring
19-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
2018
@use_alias(
2119
A="straight_line",
2220
B="frame",

pygmt/src/rose.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
"""
44

55
from pygmt.clib import Session
6-
from pygmt.helpers import (
7-
build_arg_string,
8-
check_data_input_order,
9-
fmt_docstring,
10-
kwargs_to_strings,
11-
use_alias,
12-
)
6+
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
137

148

159
@fmt_docstring
16-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
1710
@use_alias(
1811
A="sector",
1912
B="frame",

pygmt/src/surface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pygmt.helpers import (
77
GMTTempFile,
88
build_arg_string,
9-
check_data_input_order,
109
fmt_docstring,
1110
kwargs_to_strings,
1211
use_alias,
@@ -17,7 +16,6 @@
1716

1817

1918
@fmt_docstring
20-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
2119
@use_alias(
2220
I="spacing",
2321
R="region",

pygmt/src/wiggle.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@
22
wiggle - Plot z=f(x,y) anomalies along tracks.
33
"""
44
from pygmt.clib import Session
5-
from pygmt.helpers import (
6-
build_arg_string,
7-
check_data_input_order,
8-
fmt_docstring,
9-
kwargs_to_strings,
10-
use_alias,
11-
)
5+
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
126

137

148
@fmt_docstring
15-
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
169
@use_alias(
1710
B="frame",
1811
D="position",

0 commit comments

Comments
 (0)