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