Skip to content

Commit 4d4fa4f

Browse files
committed
add test for datetime64[ns]
1 parent 0a13e4f commit 4d4fa4f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from datetime import datetime
2+
3+
import numpy as np
4+
5+
import plotly.graph_objs as go
6+
7+
8+
def test_np_ns_datetime():
9+
x = [np.datetime64("2025-09-26").astype("datetime64[ns]")]
10+
y = [1.23]
11+
scatter = go.Scatter(x=x, y=y, mode="markers")
12+
13+
# x value should be converted to native datetime
14+
assert isinstance(scatter.x[0], datetime)
15+
# x value should match original numpy value at microsecond precision
16+
assert x[0].astype("datetime64[us]").item() == scatter.x[0]

0 commit comments

Comments
 (0)