@@ -13,6 +13,8 @@ from util cimport (UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX,
13
13
14
14
# core.common import for fast inference checks
15
15
16
+ npy_int64_max = np.iinfo(np.int64).max
17
+
16
18
17
19
def is_float (object obj ):
18
20
return util.is_float_object(obj)
@@ -730,6 +732,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
730
732
ndarray[float64_t] floats
731
733
ndarray[complex128_t] complexes
732
734
ndarray[int64_t] ints
735
+ ndarray[uint64_t] uints
733
736
ndarray[uint8_t] bools
734
737
ndarray[int64_t] idatetimes
735
738
ndarray[int64_t] itimedeltas
@@ -739,6 +742,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
739
742
bint seen_datetimetz = 0
740
743
bint seen_timedelta = 0
741
744
bint seen_int = 0
745
+ bint seen_uint = 0
746
+ bint seen_sint = 0
742
747
bint seen_bool = 0
743
748
bint seen_object = 0
744
749
bint seen_null = 0
@@ -751,6 +756,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
751
756
floats = np.empty(n, dtype = ' f8' )
752
757
complexes = np.empty(n, dtype = ' c16' )
753
758
ints = np.empty(n, dtype = ' i8' )
759
+ uints = np.empty(n, dtype = ' u8' )
754
760
bools = np.empty(n, dtype = np.uint8)
755
761
756
762
if convert_datetime:
@@ -806,11 +812,21 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
806
812
floats[i] = < float64_t> val
807
813
complexes[i] = < double complex > val
808
814
if not seen_null:
809
- try :
810
- ints[i] = val
811
- except OverflowError :
815
+ seen_uint = seen_uint or (val > npy_int64_max)
816
+ seen_sint = seen_sint or (val < 0 )
817
+
818
+ if seen_uint and seen_sint:
812
819
seen_object = 1
813
820
break
821
+
822
+ if seen_uint:
823
+ uints[i] = val
824
+ elif seen_sint:
825
+ ints[i] = val
826
+ else :
827
+ uints[i] = val
828
+ ints[i] = val
829
+
814
830
elif util.is_complex_object(val):
815
831
complexes[i] = val
816
832
seen_complex = 1
@@ -873,7 +889,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
873
889
elif seen_float:
874
890
return floats
875
891
elif seen_int:
876
- return ints
892
+ if seen_uint:
893
+ return uints
894
+ else :
895
+ return ints
877
896
elif (not seen_datetime and not seen_numeric
878
897
and not seen_timedelta):
879
898
return bools.view(np.bool_)
@@ -904,7 +923,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
904
923
if not seen_int:
905
924
return floats
906
925
elif seen_int:
907
- return ints
926
+ if seen_uint:
927
+ return uints
928
+ else :
929
+ return ints
908
930
elif (not seen_datetime and not seen_numeric
909
931
and not seen_timedelta):
910
932
return bools.view(np.bool_)
0 commit comments