diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index 8101416a5cd..eb2ae13448e 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -7,6 +7,7 @@ from pygmt.helpers import ( build_arg_string, data_kind, + deprecate_parameter, dummy_context, fmt_docstring, kwargs_to_strings, @@ -15,6 +16,7 @@ @fmt_docstring +@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0") @use_alias( A="annotation", B="frame", @@ -30,7 +32,7 @@ X="xshift", Y="yshift", c="panel", - i="columns", + i="incols", l="label", p="perspective", t="transparency", @@ -104,6 +106,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs): {V} {XY} {c} + {i} {p} {t} """ diff --git a/pygmt/tests/test_contour.py b/pygmt/tests/test_contour.py index 61cf0ed865c..3e285de9355 100644 --- a/pygmt/tests/test_contour.py +++ b/pygmt/tests/test_contour.py @@ -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