8000 FIX: datetime64 now recognized if in a list · matplotlib/matplotlib@1652b0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1652b0d

Browse files
committed
FIX: datetime64 now recognized if in a list
1 parent c574969 commit 1652b0d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/dates.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,18 +405,19 @@ def date2num(d):
405405
Gregorian calendar is assumed; this is not universal practice.
406406
For details see the module docstring.
407407
"""
408-
409408
if hasattr(d, "values"):
410409
# this unpacks pandas series or dataframes...
411410
d = d.values
412-
413-
if ((isinstance(d, np.ndarray) and np.issubdtype(d.dtype, np.datetime64))
414-
or isinstance(d, np.datetime64)):
415-
return _dt64_to_ordinalf(d)
416411
if not np.iterable(d):
412+
if (isinstance(d, np.datetime64) or (isinstance(d, np.ndarray) and
413+
np.issubdtype(d.dtype, np.datetime64))):
414+
return _dt64_to_ordinalf(d)
417415
return _to_ordinalf(d)
416+
418417
else:
419418
d = np.asarray(d)
419+
if np.issubdtype(d.dtype, np.datetime64):
420+
return _dt64_to_ordinalf(d)
420421
if not d.size:
421422
return d
422423
return _to_ordinalf_np_vectorized(d)

0 commit comments

Comments
 (0)
0