-
Notifications
You must be signed in to change notification settings - Fork 224
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
clib.conversion._to_numpy: Add tests for Python sequence of datetime-like objects #3758
Conversation
…datetimes or ISO-strings
Can confirm that this patch should fix the incorrect tutorial plot reported in #3757 (comment). See https://pygmt-dev--3758.org.readthedocs.build/en/3758/tutorials/advanced/date_time_charts.html#using-python-s-datetime
|
Co-authored-by: Wei Ji <[email protected]>
This PR is now ready for review. I feel we should split this PR into two small PRs, one labelled as "bug", and another one labeled as "maintenance". I guess we also need to release v0.14.1. |
I'm looking into why our unit tests didn't catch the bug at #3757, these lines in pygmt/pygmt/tests/test_plot.py Lines 469 to 472 in 9e912ba
Maybe we should extend the unit test to include # list of pandas.Timestamp
x = [pd.Timestamp("2020-1-1"), pd.Timestamp("2021-1-1")]
y = [10.5, 11.5]
fig.plot(x=x, y=y, style="h0.2c", pen="1p")
Yes, wish we hadn't merged some of those deprecation PRs yet 🙂 We could either revert those, or branch off of commit b1c984a to make a release perhaps? Maybe start a new issue for this. |
Here is the callstack: The issue is that, any datetime-like Python sequences will be converted to pygmt/pygmt/clib/conversion.py Lines 208 to 211 in 9e912ba
So, we're actually passing datetime strings into GMT. In the |
See the explanations above. As long as |
I've opened a separate PR at #3760 and also changed the base branch to |
Summary of changed imagesThis is an auto-generated report of images that have changed on the DVC remote
Image diff(s)Report last updated at commit 8b8767e |
…like objects (#3758) Co-authored-by: Wei Ji <[email protected]>
…like objects (#3758) (#3776) Co-authored-by: Wei Ji <[email protected]>
Description of proposed changes
This PR adds tests for Python sequence (list or tuple) of datetime-like objects, which usually can't be converted to np.datetime64 dtype directly by
np.ascontiguousarray
.Tested datetime-like objects include:
Need to need that, this PR still can't convert a sequence of pyarrow timestamp to np.datetime64, as shown below:
Preview for affected tutorial: https://pygmt-dev--3758.org.readthedocs.build/en/3758/tutorials/advanced/date_time_charts.html#using-python-s-datetime