Skip to content

Commit 3861935

Browse files
seismanweiji14
andauthored
Figure.histogram: Deprecate parameter "table" to "data" (remove in v0.7.0) (#1540)
Co-authored-by: Wei Ji <[email protected]>
1 parent 4bb2396 commit 3861935

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pygmt/src/histogram.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
Histogram - Create a histogram
33
"""
44
from pygmt.clib import Session
5-
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
5+
from pygmt.helpers import (
6+
build_arg_string,
7+
deprecate_parameter,
8+
fmt_docstring,
9+
kwargs_to_strings,
10+
use_alias,
11+
)
612

713

814
@fmt_docstring
15+
@deprecate_parameter("table", "data", "v0.5.0", remove_version="v0.7.0")
916
@use_alias(
1017
A="horizontal",
1118
B="frame",
@@ -41,7 +48,7 @@
4148
@kwargs_to_strings(
4249
R="sequence", T="sequence", c="sequence_comma", i="sequence_comma", p="sequence"
4350
)
44-
def histogram(self, table, **kwargs):
51+
def histogram(self, data, **kwargs):
4552
r"""
4653
Plots a histogram, and can read data from a file or
4754
list, array, or dataframe.
@@ -52,7 +59,7 @@ def histogram(self, table, **kwargs):
5259
5360
Parameters
5461
----------
55-
table : str or list or {table-like}
62+
data : str or list or {table-like}
5663
Pass in either a file name to an ASCII data table, a Python list, a 2D
5764
{table-classes}.
5865
{J}
@@ -139,7 +146,7 @@ def histogram(self, table, **kwargs):
139146
"""
140147
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
141148
with Session() as lib:
142-
file_context = lib.virtualfile_from_data(check_kind="vector", data=table)
149+
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
143150
with file_context as infile:
144151
arg_str = " ".join([infile, build_arg_string(kwargs)])
145152
lib.call_module("histogram", arg_str)

pygmt/tests/test_histogram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pygmt import Figure
88

99

10-
@pytest.fixture(scope="module", name="table", params=[list, pd.Series])
10+
@pytest.fixture(scope="module", name="data", params=[list, pd.Series])
1111
def fixture_table(request):
1212
"""
1313
Returns a list of integers to be used in the histogram.
@@ -17,13 +17,13 @@ def fixture_table(request):
1717

1818

1919
@pytest.mark.mpl_image_compare(filename="test_histogram.png")
20-
def test_histogram(table):
20+
def test_histogram(data):
2121
"""
2222
Tests plotting a histogram using a sequence of integers from a table.
2323
"""
2424
fig = Figure()
2525
fig.histogram(
26-
table=table,
26+
data=data,
2727
projection="X10c/10c",
2828
region=[0, 9, 0, 6],
2929
series=1,

0 commit comments

Comments
 (0)