Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
7 changes: 2 additions & 5 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,11 @@ def new_module(*args, **kwargs):

# timestamp (U) is deprecated since v0.9.0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR, the expected behaviors are:

  • if timestamp=True is used, Python will report the parameter is not recognized
  • if single-letter parameter U=True is used, PyGMT should tell users that U is not supported and Figure.timestamp should be used.

After removing lines 570-580, parameter timestamp is no longer recognized, but single-letter parameter U will still be processed. Thus, instead of removing these lines completely, we should change them to something like:

            # timestamp (U)is deprecated since v0.9.0.
            if "U" in kwargs:
                msg = (
                    "Parameter timestamp/U is no longer supported since v0.12.0."
                    "Use Figure.timestamp() instead."
                )
                raise GMTInvalidInput(msg)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. Thanks! I have tried to change this in the commits 6977a57, 1501ccc, and 42fab3b. I also changed this in PR #3044 for xshift (X) and yshift (Y).

Comment thread
seisman marked this conversation as resolved.
Outdated
if "U" in kwargs or "timestamp" in kwargs:
if "timestamp" in kwargs:
kwargs["U"] = kwargs.pop("timestamp")
msg = (
"Parameters 'U' and 'timestamp' are deprecated since v0.9.0 "
"and will be removed in v0.12.0. "
"Parameters 'U' and 'timestamp' are no longer supported since v0.12.0. "
"Use Figure.timestamp() instead."
)
warnings.warn(msg, category=SyntaxWarning, stacklevel=2)
raise GMTInvalidInput(msg)

# xshift (X) is deprecated since v0.8.0.
if "X" in kwargs or "xshift" in kwargs:
Expand Down
37 changes: 1 addition & 36 deletions pygmt/tests/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Test Figure.timestamp.
"""
import pytest
from pygmt import Figure, config
from pygmt import Figure


@pytest.fixture(scope="module", name="faketime")
Expand Down Expand Up @@ -93,38 +93,3 @@ def test_timestamp_text_truncated():
fig.timestamp(text="0123456789" * 7)
assert len(record) == 1 # check that only one warning was raised
return fig
Comment thread
seisman marked this conversation as resolved.


@pytest.mark.mpl_image_compare(filename="test_timestamp.png")
def test_timestamp_deprecated_timestamp(faketime):
"""
Check if the deprecated parameter 'timestamp' works but raises a warning.
"""
fig = Figure()
with pytest.warns(expected_warning=SyntaxWarning) as record:
with config(FORMAT_TIME_STAMP=faketime):
# plot nothing (the data is outside the region) but a timestamp
fig.plot(
x=0,
y=0,
style="p",
projection="X1c",
region=[1, 2, 1, 2],
timestamp=True,
)
assert len(record) == 1 # check that only one warning was raised
return fig


@pytest.mark.mpl_image_compare(filename="test_timestamp.png")
def test_timestamp_deprecated_u(faketime):
"""
Check if the deprecated parameter 'U' works but raises a warning.
"""
fig = Figure()
with pytest.warns(expected_warning=SyntaxWarning) as record:
with config(FORMAT_TIME_STAMP=faketime):
# plot nothing (the data is outside the region) but a timestamp
fig.plot(x=0, y=0, style="p", projection="X1c", region=[1, 2, 1, 2], U=True)
assert len(record) == 1 # check that only one warning was raised
return fig
Comment on lines -119 to -130

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to modify this test to check that the GMTInvalidInput exception is raised if U is used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @seisman for all your help and tips. However, I will not be able to work on this PR and PR #3044 in the next time. If you prefer to complete these two PRs soon, feel free to do so.