Skip to content

Commit

Permalink
Fix roundtrip of datetimes on ReactiveData objects (#2888)
Browse files Browse the repository at this point in the history
* Fix roundtrip of datetimes on ReactiveData objects

* Fix flakes
  • Loading branch information
philippjfr authored Nov 5, 2021
1 parent 3591f07 commit 87bfb32
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion panel/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import difflib
import datetime as dt
import re
import sys
import textwrap
Expand Down Expand Up @@ -926,8 +927,17 @@ def _process_events(self, events):
k = self._renamed_cols.get(k, k)
if isinstance(v, dict):
v = [v for _, v in sorted(v.items(), key=lambda it: int(it[0]))]
v = np.asarray(v)
old_dtype = old_raw[k].dtype
if old_dtype.kind == 'M':
v = (v * 10e5).astype(old_raw[k].dtype)
elif old_dtype.kind == 'O':
if all(isinstance(ov, dt.date) for ov in old_raw[k]):
v = np.array([dt.date.fromtimestamp(iv/1000) for iv in v])
else:
v = v.astype(old_raw[k].dtype)
try:
isequal = (old_data[k] == np.asarray(v)).all()
isequal = (old_data[k] == v).all()
except Exception:
isequal = False
if not isequal:
Expand Down

0 comments on commit 87bfb32

Please sign in to comment.