@@ -12,6 +12,8 @@ from util cimport (UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX,
12
12
13
13
# core.common import for fast inference checks
14
14
15
+ npy_int64_max = np.iinfo(np.int64).max
16
+
15
17
16
18
def is_float (object obj ):
17
19
return util.is_float_object(obj)
@@ -722,6 +724,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
722
724
ndarray[float64_t] floats
723
725
ndarray[complex128_t] complexes
724
726
ndarray[int64_t] ints
727
+ ndarray[uint64_t] uints
725
728
ndarray[uint8_t] bools
726
729
ndarray[int64_t] idatetimes
727
730
ndarray[int64_t] itimedeltas
@@ -731,6 +734,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
731
734
bint seen_datetimetz = 0
732
735
bint seen_timedelta = 0
733
736
bint seen_int = 0
737
+ bint seen_uint = 0
738
+ bint seen_sint = 0
734
739
bint seen_bool = 0
735
740
bint seen_object = 0
736
741
bint seen_null = 0
@@ -743,6 +748,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
743
748
floats = np.empty(n, dtype = ' f8' )
744
749
complexes = np.empty(n, dtype = ' c16' )
745
750
ints = np.empty(n, dtype = ' i8' )
751
+ uints = np.empty(n, dtype = ' u8' )
746
752
bools = np.empty(n, dtype = np.uint8)
747
753
748
754
if convert_datetime:
@@ -798,11 +804,21 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
798
804
floats[i] = < float64_t> val
799
805
complexes[i] = < double complex > val
800
806
if not seen_null:
801
- try :
802
- ints[i] = val
803
- except OverflowError :
807
+ seen_uint = seen_uint or (val > npy_int64_max)
808
+ seen_sint = seen_sint or (val < 0 )
809
+
810
+ if seen_uint and seen_sint:
804
811
seen_object = 1
805
812
break
813
+
814
+ if seen_uint:
815
+ uints[i] = val
816
+ elif seen_sint:
817
+ ints[i] = val
818
+ else :
819
+ uints[i] = val
820
+ ints[i] = val
821
+
806
822
elif util.is_complex_object(val):
807
823
complexes[i] = val
808
824
seen_complex = 1
@@ -865,7 +881,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
865
881
elif seen_float:
866
882
return floats
867
883
elif seen_int:
868
- return ints
884
+ if seen_uint:
885
+ return uints
886
+ else :
887
+ return ints
869
888
elif (not seen_datetime and not seen_numeric
870
889
and not seen_timedelta):
871
890
return bools.view(np.bool_)
@@ -896,7 +915,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
896
915
if not seen_int:
897
916
return floats
898
917
elif seen_int:
899
- return ints
918
+ if seen_uint:
919
+ return uints
920
+ else :
921
+ return ints
900
922
elif (not seen_datetime and not seen_numeric
901
923
and not seen_timedelta):
902
924
return bools.view(np.bool_)
0 commit comments