@@ -305,7 +305,7 @@ def _from_ordinalf(x, tz=None):
305
305
306
306
307
307
# a version of _from_ordinalf that can operate on numpy arrays
308
- _from_ordinalf_np_vectorized = np .vectorize (_from_ordinalf )
308
+ _from_ordinalf_np_vectorized = np .vectorize (_from_ordinalf , otypes = "O" )
309
309
310
310
311
311
@cbook .deprecated (
@@ -498,20 +498,11 @@ def num2date(x, tz=None):
498
498
"""
499
499
if tz is None :
500
500
tz = _get_rc_timezone ()
501
- if not np .iterable (x ):
502
- return _from_ordinalf (x , tz )
503
- else :
504
- x = np .asarray (x )
505
- if not x .size :
506
- return x
507
- return _from_ordinalf_np_vectorized (x , tz ).tolist ()
508
-
509
-
510
- def _ordinalf_to_timedelta (x ):
511
- return datetime .timedelta (days = x )
501
+ return _from_ordinalf_np_vectorized (x , tz ).tolist ()
512
502
513
503
514
- _ordinalf_to_timedelta_np_vectorized = np .vectorize (_ordinalf_to_timedelta )
504
+ _ordinalf_to_timedelta_np_vectorized = np .vectorize (
505
+ lambda x : datetime .timedelta (days = x ), otypes = "O" )
515
506
516
507
517
508
def num2timedelta (x ):
@@ -529,15 +520,8 @@ def num2timedelta(x):
529
520
Returns
530
521
-------
531
522
`datetime.timedelta` or list[`datetime.timedelta`]
532
-
533
523
"""
534
- if not np .iterable (x ):
535
- return _ordinalf_to_timedelta (x )
536
- else :
537
- x = np .asarray (x )
538
- if not x .size :
539
- return x
540
- return _ordinalf_to_timedelta_np_vectorized (x ).tolist ()
524
+ return _ordinalf_to_timedelta_np_vectorized (x ).tolist ()
541
525
542
526
543
527
def drange (dstart , dend , delta ):
0 commit comments