Skip to content

Commit e750d0d

Browse files
willschlitzerMeghan Jonesmichaelgrundseisman
authored
Figure.plot3d: Deprecate parameter "columns" to "incols" (remove in v0.6.0) (#1040)
* Add "incols" parameter in plot3d.py * change data accepted types to include table-like * add @deprecate_parameter for columns parameter * add test for deprecated "columns" parameter in plot3d Co-authored-by: Meghan Jones <meghanj@hawaii.edu> Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
1 parent ab837d4 commit e750d0d

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

pygmt/src/plot3d.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616

1717
@fmt_docstring
18+
@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0")
19+
@deprecate_parameter("sizes", "size", "v0.4.0", remove_version="v0.6.0")
1820
@use_alias(
1921
A="straight_line",
2022
B="frame",
@@ -36,15 +38,14 @@
3638
Y="yshift",
3739
Z="zvalue",
3840
a="aspatial",
39-
i="columns",
41+
i="incols",
4042
l="label",
4143
c="panel",
4244
f="coltypes",
4345
p="perspective",
4446
t="transparency",
4547
)
4648
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
47-
@deprecate_parameter("sizes", "size", "v0.4.0", remove_version="v0.6.0")
4849
def plot3d(
4950
self, x=None, y=None, z=None, data=None, size=None, direction=None, **kwargs
5051
):
@@ -79,10 +80,9 @@ def plot3d(
7980
The x, y, and z coordinates, or arrays of x, y and z coordinates of
8081
the data points
8182
data : str or {table-like}
82-
Pass in either a file name to an ASCII data table, a 2D
83-
{table-classes}.
84-
Use parameter ``columns`` to choose which columns are x, y, z, color,
85-
and size, respectively.
83+
Either a data file name, a 2d {table-classes}.
84+
Optionally, use parameter ``incols`` to specify which columns are x, y,
85+
z, color, and size, respectively.
8686
size : 1d array
8787
The size of the data points in units specified in ``style``.
8888
Only valid if using ``x``/``y``/``z``.
@@ -163,6 +163,7 @@ def plot3d(
163163
{a}
164164
{c}
165165
{f}
166+
{i}
166167
label : str
167168
Add a legend entry for the symbol or line being plotted.
168169
{p}

pygmt/tests/test_plot3d.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def test_plot3d_sizes_colors_transparencies():
356356
@pytest.mark.mpl_image_compare
357357
def test_plot3d_matrix(data, region):
358358
"""
359-
Plot the data passing in a matrix and specifying columns.
359+
Plot the data passing in a matrix and specifying incols.
360360
"""
361361
fig = Figure()
362362
fig.plot3d(
@@ -368,7 +368,7 @@ def test_plot3d_matrix(data, region):
368368
style="c1c",
369369
color="#aaaaaa",
370370
frame=["a", "za"],
371-
columns="0,1,2",
371+
incols="0,1,2",
372372
)
373373
return fig
374374

@@ -391,7 +391,7 @@ def test_plot3d_matrix_color(data, region):
391391
projection="X10c",
392392
style="c0.5c",
393393
cmap="rainbow",
394-
columns=[0, 1, 2, 2],
394+
incols=[0, 1, 2, 2],
395395
frame=["a", "za"],
396396
)
397397
return fig
@@ -412,7 +412,7 @@ def test_plot3d_from_file(region):
412412
style="d1c",
413413
color="yellow",
414414
frame=["af", "zaf"],
415-
columns=[0, 1, 2],
415+
incols=[0, 1, 2],
416416
)
417417
return fig
418418

@@ -492,3 +492,28 @@ def test_plot3d_deprecate_sizes_to_size(data, region):
492492
)
493493
assert len(record) == 1 # check that only one warning was raised
494494
return fig
495+
496+
497+
@pytest.mark.mpl_image_compare(filename="test_plot3d_matrix.png")
498+
def test_plot3d_deprecate_columns_to_incols(data, region):
499+
"""
500+
Make sure that the old parameter "columns" is supported and it reports an
501+
warning.
502+
503+
Modified from the test_plot3d_matrix() test.
504+
"""
505+
fig = Figure()
506+
with pytest.warns(expected_warning=FutureWarning) as record:
507+
fig.plot3d(
508+
data=data,
509+
zscale=5,
510+
perspective=[225, 30],
511+
region=region,
512+
projection="M20c",
513+
style="c1c",
514+
color="#aaaaaa",
515+
frame=["a", "za"],
516+
columns="0,1,2",
517+
)
518+
assert len(record) == 1 # check that only one warning was raised
519+
return fig

0 commit comments

Comments
 (0)