Skip to content

Commit

Permalink
Figure.histogram: Deprecate parameter "table" to "data" (remove in v0…
Browse files Browse the repository at this point in the history
….7.0) (#1540)

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
  • Loading branch information
seisman and weiji14 authored Sep 27, 2021
1 parent 4bb2396 commit 3861935
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions pygmt/src/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
Histogram - Create a histogram
"""
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("table", "data", "v0.5.0", remove_version="v0.7.0")
@use_alias(
A="horizontal",
B="frame",
Expand Down Expand Up @@ -41,7 +48,7 @@
@kwargs_to_strings(
R="sequence", T="sequence", c="sequence_comma", i="sequence_comma", p="sequence"
)
def histogram(self, table, **kwargs):
def histogram(self, data, **kwargs):
r"""
Plots a histogram, and can read data from a file or
list, array, or dataframe.
Expand All @@ -52,7 +59,7 @@ def histogram(self, table, **kwargs):
Parameters
----------
table : str or list or {table-like}
data : str or list or {table-like}
Pass in either a file name to an ASCII data table, a Python list, a 2D
{table-classes}.
{J}
Expand Down Expand Up @@ -139,7 +146,7 @@ def histogram(self, table, **kwargs):
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
with Session() as lib:
file_context = lib.virtualfile_from_data(check_kind="vector", data=table)
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
with file_context as infile:
arg_str = " ".join([infile, build_arg_string(kwargs)])
lib.call_module("histogram", arg_str)
6 changes: 3 additions & 3 deletions pygmt/tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pygmt import Figure


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


@pytest.mark.mpl_image_compare(filename="test_histogram.png")
def test_histogram(table):
def test_histogram(data):
"""
Tests plotting a histogram using a sequence of integers from a table.
"""
fig = Figure()
fig.histogram(
table=table,
data=data,
projection="X10c/10c",
region=[0, 9, 0, 6],
series=1,
Expand Down

0 comments on commit 3861935

Please sign in to comment.