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.plot3d: Deprecate parameter "columns" to "incols" (remove in v0.6.0) #1040

Merged
merged 13 commits into from
Jun 17, 2021
Merged
13 changes: 7 additions & 6 deletions pygmt/src/plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@


@fmt_docstring
@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0")
@deprecate_parameter("sizes", "size", "v0.4.0", remove_version="v0.6.0")
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
@use_alias(
A="straight_line",
B="frame",
Expand All @@ -36,15 +38,14 @@
Y="yshift",
Z="zvalue",
a="aspatial",
i="columns",
i="incols",
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
l="label",
c="panel",
f="coltypes",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
@deprecate_parameter("sizes", "size", "v0.4.0", remove_version="v0.6.0")
def plot3d(
self, x=None, y=None, z=None, data=None, size=None, direction=None, **kwargs
):
Expand Down Expand Up @@ -79,10 +80,9 @@ def plot3d(
The x, y, and z coordinates, or arrays of x, y and z coordinates of
the data points
data : str or {table-like}
Pass in either a file name to an ASCII data table, a 2D
{table-classes}.
Use parameter ``columns`` to choose which columns are x, y, z, color,
and size, respectively.
Either a data file name, a 2d {table-classes}.
Optionally, use parameter ``incols`` to specify which columns are x, y,
z, color, and size, respectively.
size : 1d array
The size of the data points in units specified in ``style``.
Only valid if using ``x``/``y``/``z``.
Expand Down Expand Up @@ -163,6 +163,7 @@ def plot3d(
{a}
{c}
{f}
{i}
label : str
Add a legend entry for the symbol or line being plotted.
{p}
Expand Down
33 changes: 29 additions & 4 deletions pygmt/tests/test_plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_plot3d_sizes_colors_transparencies():
@pytest.mark.mpl_image_compare
def test_plot3d_matrix(data, region):
"""
Plot the data passing in a matrix and specifying columns.
Plot the data passing in a matrix and specifying incols.
"""
fig = Figure()
fig.plot3d(
Expand All @@ -368,7 +368,7 @@ def test_plot3d_matrix(data, region):
style="c1c",
color="#aaaaaa",
frame=["a", "za"],
columns="0,1,2",
incols="0,1,2",
)
return fig

Expand All @@ -391,7 +391,7 @@ def test_plot3d_matrix_color(data, region):
projection="X10c",
style="c0.5c",
cmap="rainbow",
columns=[0, 1, 2, 2],
incols=[0, 1, 2, 2],
frame=["a", "za"],
)
return fig
Expand All @@ -412,7 +412,7 @@ def test_plot3d_from_file(region):
style="d1c",
color="yellow",
frame=["af", "zaf"],
columns=[0, 1, 2],
incols=[0, 1, 2],
)
return fig

Expand Down Expand Up @@ -492,3 +492,28 @@ def test_plot3d_deprecate_sizes_to_size(data, region):
)
assert len(record) == 1 # check that only one warning was raised
return fig


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

Modified from the test_plot3d_matrix() test.
"""
fig = Figure()
with pytest.warns(expected_warning=FutureWarning) as record:
fig.plot3d(
data=data,
zscale=5,
perspective=[225, 30],
region=region,
projection="M20c",
style="c1c",
color="#aaaaaa",
frame=["a", "za"],
columns="0,1,2",
)
assert len(record) == 1 # check that only one warning was raised
return fig