@@ -455,18 +455,18 @@ cpdef array_to_datetime(
455
455
set out_tzoffset_vals = set ()
456
456
tzinfo tz_out = None
457
457
bint found_tz = False , found_naive = False
458
- cnp.broadcast mi
458
+ cnp.flatiter it = cnp.PyArray_IterNew(values)
459
459
460
460
# specify error conditions
461
461
assert is_raise or is_ignore or is_coerce
462
462
463
463
result = np.empty((< object > values).shape, dtype = " M8[ns]" )
464
- mi = cnp.PyArray_MultiIterNew2(result, values)
465
464
iresult = result.view(" i8" ).ravel()
466
465
467
466
for i in range (n):
468
467
# Analogous to `val = values[i]`
469
- val = < object > (< PyObject** > cnp.PyArray_MultiIter_DATA(mi, 1 ))[0 ]
468
+ val = cnp.PyArray_GETITEM(values, cnp.PyArray_ITER_DATA(it))
469
+ cnp.PyArray_ITER_NEXT(it)
470
470
471
471
try :
472
472
if checknull_with_nat_and_na(val):
@@ -511,7 +511,6 @@ cpdef array_to_datetime(
511
511
if parse_today_now(val, & iresult[i], utc):
512
512
# We can't _quite_ dispatch this to convert_str_to_tsobject
513
513
# bc there isn't a nice way to pass "utc"
514
- cnp.PyArray_MultiIter_NEXT(mi)
515
514
continue
516
515
517
516
_ts = convert_str_to_tsobject(
@@ -540,13 +539,10 @@ cpdef array_to_datetime(
540
539
else :
541
540
raise TypeError (f" {type(val)} is not convertible to datetime" )
542
541
543
- cnp.PyArray_MultiIter_NEXT(mi)
544
-
545
542
except (TypeError , OverflowError , ValueError ) as ex:
546
543
ex.args = (f" {ex}, at position {i}" ,)
547
544
if is_coerce:
548
545
iresult[i] = NPY_NAT
549
- cnp.PyArray_MultiIter_NEXT(mi)
550
546
continue
551
547
elif is_raise:
552
548
raise
0 commit comments