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.histogram: Deprecate parameter "table" to "data" (remove in v0.7.0) #1540

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 12 additions & 5 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 @@ -51,8 +58,8 @@ def histogram(self, table, **kwargs):
{aliases}

Parameters
----------
table : str or list or {table-like}
---------
seisman marked this conversation as resolved.
Show resolved Hide resolved
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