Skip to content

Commit 32f3857

Browse files
committed
Fixed serialization of NumPy dtype M values to milliseconds rather than nanoseconds.
1 parent 0cd35bc commit 32f3857

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

highcharts_core/options/series/data/cartesian.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def x(self, value):
128128
value = validators.datetime(value)
129129
elif checkers.is_date(value):
130130
value = validators.date(value)
131+
elif HAS_NUMPY and hasattr(value, 'dtype') and value.dtype.char == 'M':
132+
value = (value.astype(np.int64) / 10**6).astype(np.int64)
131133
elif checkers.is_numeric(value):
132134
value = validators.numeric(value)
133135
else:

highcharts_core/utility_functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,10 @@ def from_ndarray(as_ndarray, force_enforced_null = False):
688688
else:
689689
nan_replacement = None
690690

691-
if as_ndarray.dtype.char not in ['O', 'U']:
691+
if as_ndarray.dtype.char not in ['O', 'U', 'M']:
692692
stripped = np.where(np.isnan(as_ndarray), nan_replacement, as_ndarray)
693+
elif as_ndarray.dtype.char == 'M':
694+
stripped = (as_ndarray.astype(np.int64) / 10**6).astype(np.int64)
693695
else:
694696
prelim_stripped = as_ndarray.tolist()
695697
stripped = []

0 commit comments

Comments
 (0)