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: Remove deprecated "timestamp" ("U") parameter, use "Figure.timestamp" instead (deprecated since v0.9.0) #3045

Merged
merged 15 commits into from
Feb 28, 2024

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Feb 6, 2024

Description of proposed changes

This PR removes the deprecated timestampe (U) parameter from all plotting methods (deprecated since v0.9.0).
The standalone method Figure.timestamp should be used instead.

Fixes partly #3033
Related to #2135

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@yvonnefroehlich yvonnefroehlich added the deprecation Deprecating a feature label Feb 6, 2024
@yvonnefroehlich yvonnefroehlich changed the title All plotting methods: Remove deprecated 'timestamp' ('U') parameter, use 'Figure.timestamp' instead (deprecated since v0.9.0) All plotting methods: Remove deprecated "timestamp" ("U") parameter, use "Figure.timestamp" instead (deprecated since v0.9.0) Feb 6, 2024
@@ -567,17 +567,6 @@ def new_module(*args, **kwargs):
)
warnings.warn(msg, category=SyntaxWarning, stacklevel=2)

# timestamp (U) is deprecated since v0.9.0.
Copy link
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
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).

@seisman seisman added this to the 0.12.0 milestone Feb 18, 2024
@yvonnefroehlich yvonnefroehlich self-assigned this Feb 18, 2024
Comment on lines 119 to 130
@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
Copy link
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
Member

Choose a reason for hiding this comment

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

Copy link
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.

@seisman
Copy link
Member

seisman commented Feb 27, 2024

/format

@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Feb 27, 2024
@seisman seisman merged commit 12df978 into main Feb 28, 2024
20 of 21 checks passed
@seisman seisman deleted the rem-depr-timestamp branch February 28, 2024 01:58
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Feb 28, 2024
@seisman seisman changed the title All plotting methods: Remove deprecated "timestamp" ("U") parameter, use "Figure.timestamp" instead (deprecated since v0.9.0) Figure: Remove deprecated "timestamp" ("U") parameter, use "Figure.timestamp" instead (deprecated since v0.9.0) Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Deprecating a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants