@@ -4,7 +4,7 @@ from cython import Py_ssize_t
4
4
5
5
import numpy as np
6
6
cimport numpy as cnp
7
- from numpy cimport int64_t, int32_t, ndarray
7
+ from numpy cimport uint8_t, int64_t, int32_t, ndarray
8
8
cnp.import_array()
9
9
10
10
import pytz
@@ -535,6 +535,7 @@ cdef inline void localize_tso(_TSObject obj, tzinfo tz):
535
535
int64_t[:] deltas
536
536
int64_t local_val
537
537
Py_ssize_t pos
538
+ str typ
538
539
539
540
assert obj.tzinfo is None
540
541
@@ -646,7 +647,7 @@ cdef inline int64_t[:] _tz_convert_dst(int64_t[:] values, tzinfo tz,
646
647
if not is_tzlocal(tz):
647
648
# get_dst_info cannot extract offsets from tzlocal because its
648
649
# dependent on a datetime
649
- trans, deltas, typ = get_dst_info(tz)
650
+ trans, deltas, _ = get_dst_info(tz)
650
651
if not to_utc:
651
652
# We add `offset` below instead of subtracting it
652
653
deltas = - 1 * np.array(deltas, dtype = ' i8' )
@@ -690,7 +691,7 @@ cdef inline int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz,
690
691
"""
691
692
cdef:
692
693
npy_datetimestruct dts
693
- int64_t result, delta
694
+ int64_t delta
694
695
datetime dt
695
696
696
697
dt64_to_dtstruct(val, & dts)
@@ -879,18 +880,20 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
879
880
localized : ndarray[int64_t]
880
881
"""
881
882
cdef:
882
- ndarray[int64_t] trans
883
883
int64_t[:] deltas, idx_shifted, idx_shifted_left, idx_shifted_right
884
- ndarray ambiguous_array
884
+ ndarray[uint8_t, cast = True ] ambiguous_array, both_nat, both_eq
885
885
Py_ssize_t i, idx, pos, ntrans, n = len (vals)
886
886
Py_ssize_t delta_idx_offset, delta_idx, pos_left, pos_right
887
887
int64_t * tdata
888
888
int64_t v, left, right, val, v_left, v_right, new_local, remaining_mins
889
889
int64_t HOURS_NS = HOUR_SECONDS * 1000000000
890
- ndarray[int64_t] result, result_a, result_b, dst_hours
890
+ ndarray[int64_t] trans, result, result_a, result_b, dst_hours
891
+ ndarray[int64_t] trans_idx, grp, delta, a_idx, b_idx, one_diff
891
892
npy_datetimestruct dts
892
893
bint infer_dst = False , is_dst = False , fill = False
893
894
bint shift = False , fill_nonexist = False
895
+ list trans_grp
896
+ str stamp
894
897
895
898
# Vectorized version of DstTzInfo.localize
896
899
if is_utc(tz) or tz is None :
@@ -923,7 +926,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
923
926
if len (ambiguous) != len (vals):
924
927
raise ValueError (" Length of ambiguous bool-array must be "
925
928
" the same size as vals" )
926
- ambiguous_array = np.asarray(ambiguous)
929
+ ambiguous_array = np.asarray(ambiguous, dtype = bool )
927
930
928
931
if nonexistent == ' NaT' :
929
932
fill_nonexist = True
@@ -933,7 +936,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
933
936
assert nonexistent in (' raise' , None ), (" nonexistent must be one of"
934
937
" {'NaT', 'raise', 'shift'}" )
935
938
936
- trans, deltas, typ = get_dst_info(tz)
939
+ trans, deltas, _ = get_dst_info(tz)
937
940
938
941
tdata = < int64_t* > cnp.PyArray_DATA(trans)
939
942
ntrans = len (trans)
@@ -984,7 +987,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
984
987
# years which is useful for checking that there is not an ambiguous
985
988
# transition in an individual year.
986
989
if trans_idx.size > 0 :
987
- one_diff = np.where(np.diff(trans_idx) != 1 )[0 ] + 1
990
+ one_diff = np.where(np.diff(trans_idx) != 1 )[0 ] + 1
988
991
trans_grp = np.array_split(trans_idx, one_diff)
989
992
990
993
# Iterate through each day, if there are no hours where the
@@ -1172,13 +1175,14 @@ cdef int64_t[:] _normalize_local(int64_t[:] stamps, tzinfo tz):
1172
1175
result : int64 ndarray of converted of normalized nanosecond timestamps
1173
1176
"""
1174
1177
cdef:
1175
- Py_ssize_t n = len (stamps)
1178
+ Py_ssize_t i, n = len (stamps)
1176
1179
int64_t[:] result = np.empty(n, dtype = np.int64)
1177
1180
ndarray[int64_t] trans
1178
1181
int64_t[:] deltas
1182
+ str typ
1179
1183
Py_ssize_t[:] pos
1180
1184
npy_datetimestruct dts
1181
- int64_t delta
1185
+ int64_t delta, local_val
1182
1186
1183
1187
if is_utc(tz):
1184
1188
with nogil:
@@ -1264,6 +1268,7 @@ def is_date_array_normalized(int64_t[:] stamps, object tz=None):
1264
1268
int64_t[:] deltas
1265
1269
npy_datetimestruct dts
1266
1270
int64_t local_val, delta
1271
+ str typ
1267
1272
1268
1273
if tz is None or is_utc(tz):
1269
1274
for i in range (n):
0 commit comments