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

Fix the bug of converting Python sequence of datetime-like objects #3760

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seisman
Copy link
Member

@seisman seisman commented Jan 9, 2025

Cherry-picked from #3758. Tests will be added in #3758.

Fixes #3757.

@seisman seisman added the bug Something isn't working label Jan 9, 2025
@seisman seisman added this to the 0.15.0 milestone Jan 9, 2025
@seisman seisman added the needs review This PR has higher priority and needs review. label Jan 9, 2025
weiji14
weiji14 previously approved these changes Jan 9, 2025
@weiji14 weiji14 dismissed their stale review January 9, 2025 18:08

Decided that #3758 (comment) might be worth adding

@weiji14
Copy link
Member

weiji14 commented Jan 9, 2025

Originally posted by @seisman in #3758 (comment)

Maybe we should extend the unit test to include pandas.Timestamp? E.g. adding these lines:

    # 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")

See the explanations above. As long as _to_numpy can convert a datetime-like object into np.datetime64 array correctly, PyGMT should be able to plot/process it. So, I think the newly added tests are enough.

Still think we should have an integration test of some sort for Sequence[pd.Timestamp], or maybe Sequence[pyarrow.TimestampScalar]. We should cover both np.object_ and np.str_ type arrays, in case the internal virtualfile_from_vectors->vectors_to_arrays->_to_numpy logic ever changes.

@weiji14 weiji14 modified the milestones: 0.15.0, 0.14.1 Jan 9, 2025
@seisman
Copy link
Member Author

seisman commented Jan 10, 2025

OK, added a test in 892f444.

@seisman seisman mentioned this pull request Jan 10, 2025
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review This PR has higher priority and needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plot no longer accepts date/time data in pygmt 0.14
2 participants