Skip to content

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

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

Merged
merged 7 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pygmt/src/rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
"""

from pygmt.clib import Session
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
from pygmt.helpers import (
build_arg_string,
deprecate_parameter,
fmt_docstring,
kwargs_to_strings,
use_alias,
)


@fmt_docstring
@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0")
@use_alias(
A="sector",
B="frame",
Expand All @@ -29,7 +36,7 @@
X="xshift",
Y="yshift",
Z="scale",
i="columns",
i="incols",
c="panel",
p="perspective",
t="transparency",
Expand Down Expand Up @@ -108,12 +115,6 @@ def rose(self, length=None, azimuth=None, data=None, **kwargs):
consideration, set them all to unity with ``scale = 'u'``
[Default is no scaling].

columns : str or 1d array
Select input columns and transformations. E.g. choose
``columns = [1, 0]`` or ``columns = '1,0'`` if the length values
are stored in the second column and the direction (azimuth)
values in the first one. Note: zero-based indexing is used.

color : str
Selects shade, color or pattern for filling the sectors [Default
is no fill].
Expand Down Expand Up @@ -186,6 +187,7 @@ def rose(self, length=None, azimuth=None, data=None, **kwargs):
{V}
{XY}
{c}
{i}
{p}
{t}
"""
Expand Down
37 changes: 33 additions & 4 deletions pygmt/tests/test_rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_rose_data_file(data_fractures_compilation):
diameter="5.5c",
color="blue",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
columns=[1, 0],
incols=[1, 0],
pen="1p",
norm="",
scale=0.4,
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_rose_plot_with_transparency(data_fractures_compilation):
diameter="5.5c",
color="blue",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
columns=[1, 0],
incols=[1, 0],
pen="1p",
norm=True,
scale=0.4,
Expand All @@ -151,7 +151,7 @@ def test_rose_no_sectors(data_fractures_compilation):
fig.rose(
data=data_fractures_compilation,
region=[0, 500, 0, 360],
columns="1,0",
incols="1,0",
diameter="10c",
labels="180/0/90/270",
frame=["xg100", "yg45", "+t'Windrose diagram'"],
Expand All @@ -176,7 +176,7 @@ def test_rose_bools(data_fractures_compilation):
data=data_fractures_compilation,
region=[0, 1, 0, 360],
sector=10,
columns=[1, 0],
incols=[1, 0],
diameter="10c",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
color="red3",
Expand All @@ -188,3 +188,32 @@ def test_rose_bools(data_fractures_compilation):
shift=False,
)
return fig


@pytest.mark.mpl_image_compare(filename="test_rose_bools.png")
def test_rose_deprecate_columns_to_incols(data_fractures_compilation):
"""
Make sure that the old parameter "columns" is supported and it reports a
warning.

Modified from the test_rose_bools() test.
"""
fig = Figure()
with pytest.warns(expected_warning=FutureWarning) as record:
fig.rose(
data=data_fractures_compilation,
region=[0, 1, 0, 360],
sector=10,
columns=[1, 0],
diameter="10c",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
color="red3",
pen="1p",
orientation=False,
norm=True,
vectors=True,
no_scale=True,
shift=False,
)
assert len(record) == 1 # check that only one warning was raised
return fig