Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure.contour: Deprecate parameter "columns" to "incols" (remove in v0.6.0) #1303

Merged
merged 13 commits into from
Jun 6, 2021
5 changes: 4 additions & 1 deletion pygmt/src/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pygmt.helpers import (
build_arg_string,
data_kind,
deprecate_parameter,
dummy_context,
fmt_docstring,
kwargs_to_strings,
Expand All @@ -15,6 +16,7 @@


@fmt_docstring
@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0")
@use_alias(
A="annotation",
B="frame",
Expand All @@ -30,7 +32,7 @@
X="xshift",
Y="yshift",
c="panel",
i="columns",
i="incols",
l="label",
p="perspective",
t="transparency",
Expand Down Expand Up @@ -104,6 +106,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
{V}
{XY}
{c}
{i}
{p}
{t}
"""
Expand Down
34 changes: 34 additions & 0 deletions pygmt/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,37 @@ def test_contour_from_file(region):
data=POINTS_DATA, projection="X10c", region=region, frame="af", pen="#ffcb87"
)
return fig


@pytest.mark.mpl_image_compare(filename="test_contour_vec.png")
def test_contour_deprecate_columns_to_incols(region):
"""
Make sure that the old parameter "columns" is supported and it reports an
warning.

Modified from the test_contour_vec() test.
"""
fig = Figure()
x, y = np.meshgrid(
np.linspace(region[0], region[1]), np.linspace(region[2], region[3])
)
x = x.flatten()
y = y.flatten()
z = (x - 0.5 * (region[0] + region[1])) ** 2 + 4 * y ** 2
z = np.exp(-z / 10 ** 2 * np.log(2))

# generate dataframe
# switch x and y from here onwards to simulate different column order
data = np.array([y, x, z]).T

with pytest.warns(expected_warning=FutureWarning) as record:
fig.contour(
data=data,
projection="X10c",
region=region,
frame="a",
pen=True,
columns=[1, 0, 2],
)
assert len(record) == 1 # check that only one warning was raised
return fig