GeezerVison is showing github.com — Figure: Remove deprecated "timestamp" ("U") parameter, use "Figure.timestamp" instead (deprecated since v0.9.0) by yvonnefroehlich · Pull Request #3045 · GenericMappingTools/pygmt
Conversation
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
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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
|
|
)
|
|
|
warnings.warn(msg, category=SyntaxWarning, stacklevel=2)
|
|
|
|
|
|
# timestamp (U) is deprecated since v0.9.0.
|
There was a problem hiding this comment.
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)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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
|
There was a problem hiding this comment.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
genericmappingtools-bot[bot] reacted with hooray emoji
github-actions[bot] reacted with rocket emoji
github-actions[bot] reacted with eyes emoji
All reactions
-
🎉
1 reaction
-
🚀
1 reaction
-
👀
1 reaction
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
Reviewers
seisman
seisman approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|