Skip to content

Conversation

@seisman
Copy link
Member

@seisman seisman commented Jan 17, 2026

Related to #2848.

import pygmt
import numpy as np

fig = pygmt.Figure()
fig.basemap(
    projection="X8c/5c",
    region=[np.timedelta64(0, "D"), np.timedelta64(8, "D"), 0, 10],
    frame=["WSne", "xaf+lForecast Days", "yaf+lRMSE"],
)
fig.plot(
    x=np.arange(np.timedelta64(0, "D"), np.timedelta64(8, "D")),
    y=np.geomspace(start=0.1, stop=9, num=8),
    style="c0.2c",
    pen="1p",
)
fig.show()
timedelta64

@seisman seisman added this to the 0.19.0 milestone Jan 17, 2026
@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. run/benchmark Trigger the benchmark workflow in PRs labels Jan 17, 2026
@seisman seisman requested review from Copilot and weiji14 January 17, 2026 13:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for passing np.timedelta64 objects to parameters that expect a sequence, such as the region parameter in GMT plotting functions. The implementation converts timedelta64 objects to their numeric values in their original units when joining sequences into strings.

Changes:

  • Modified sequence_join function in pygmt/helpers/utils.py to handle np.timedelta64 objects by extracting their numeric values
  • Updated test_plot_timedelta64 test to use timedelta64 objects in the region parameter, testing the new functionality
  • Added comprehensive docstring examples showing timedelta64 handling with various time units

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pygmt/helpers/utils.py Added timedelta64 handling logic to convert timedelta64 objects to numeric strings, and updated docstring with examples
pygmt/tests/test_plot.py Refactored test to use timedelta64 objects in the region parameter, testing the new functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 17, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing timedelta64/support (e222f52) with main (88dcf01)1

Summary

✅ 104 untouched benchmarks

Footnotes

  1. No successful run was found on main (2276659) during the generation of this report, so 88dcf01 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@seisman seisman force-pushed the timedelta64/support branch from 2fca0be to e222f52 Compare January 17, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature needs review This PR has higher priority and needs review. run/benchmark Trigger the benchmark workflow in PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants