@@ -753,10 +753,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
753
753
@classmethod
754
754
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
755
755
data = tuple (data )
756
- non_float = tuple (item for item in data if not isinstance (item , float ))
756
+ non_float_gen = (item for item in data if not isinstance (item , float ))
757
+ non_float = next (non_float_gen , None )
757
758
if non_float :
758
759
raise TypeError (
759
- f"Cannot build f64 vector from { type (non_float [ 0 ] ).__name__ } , "
760
+ f"Cannot build f64 vector from { type (non_float ).__name__ } , "
760
761
"expected float."
761
762
)
762
763
return cls (_np .fromiter (data , dtype = _np .dtype (">f8" )).tobytes ())
@@ -826,10 +827,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
826
827
@classmethod
827
828
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
828
829
data = tuple (data )
829
- non_float = tuple (item for item in data if not isinstance (item , float ))
830
+ non_float_gen = (item for item in data if not isinstance (item , float ))
831
+ non_float = next (non_float_gen , None )
830
832
if non_float :
831
833
raise TypeError (
832
- f"Cannot build f32 vector from { type (non_float [ 0 ] ).__name__ } , "
834
+ f"Cannot build f32 vector from { type (non_float ).__name__ } , "
833
835
"expected float."
834
836
)
835
837
return cls (_np .fromiter (data , dtype = _np .dtype (">f4" )).tobytes ())
@@ -903,10 +905,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
903
905
@classmethod
904
906
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
905
907
data = tuple (data )
906
- non_int = tuple (item for item in data if not isinstance (item , int ))
908
+ non_int_gen = (item for item in data if not isinstance (item , int ))
909
+ non_int = next (non_int_gen , None )
907
910
if non_int :
908
911
raise TypeError (
909
- f"Cannot build i64 vector from { type (non_int [ 0 ] ).__name__ } , "
912
+ f"Cannot build i64 vector from { type (non_int ).__name__ } , "
910
913
"expected int."
911
914
)
912
915
data = _t .cast (tuple [int , ...], data )
@@ -994,10 +997,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
994
997
@classmethod
995
998
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
996
999
data = tuple (data )
997
- non_int = tuple (item for item in data if not isinstance (item , int ))
1000
+ non_int_gen = (item for item in data if not isinstance (item , int ))
1001
+ non_int = next (non_int_gen , None )
998
1002
if non_int :
999
1003
raise TypeError (
1000
- f"Cannot build i32 vector from { type (non_int [ 0 ] ).__name__ } , "
1004
+ f"Cannot build i32 vector from { type (non_int ).__name__ } , "
1001
1005
"expected int."
1002
1006
)
1003
1007
data = _t .cast (tuple [int , ...], data )
@@ -1085,10 +1089,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
1085
1089
@classmethod
1086
1090
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
1087
1091
data = tuple (data )
1088
- non_int = tuple (item for item in data if not isinstance (item , int ))
1092
+ non_int_gen = (item for item in data if not isinstance (item , int ))
1093
+ non_int = next (non_int_gen , None )
1089
1094
if non_int :
1090
1095
raise TypeError (
1091
- f"Cannot build i16 vector from { type (non_int [ 0 ] ).__name__ } , "
1096
+ f"Cannot build i16 vector from { type (non_int ).__name__ } , "
1092
1097
"expected int."
1093
1098
)
1094
1099
data = _t .cast (tuple [int , ...], data )
@@ -1176,10 +1181,11 @@ def _from_native_rust(cls, data: _t.Iterable[object], /) -> _t.Self:
1176
1181
@classmethod
1177
1182
def _from_native_np (cls , data : _t .Iterable [object ], / ) -> _t .Self :
1178
1183
data = tuple (data )
1179
- non_int = tuple (item for item in data if not isinstance (item , int ))
1184
+ non_int_gen = (item for item in data if not isinstance (item , int ))
1185
+ non_int = next (non_int_gen , None )
1180
1186
if non_int :
1181
1187
raise TypeError (
1182
- f"Cannot build i8 vector from { type (non_int [ 0 ] ).__name__ } , "
1188
+ f"Cannot build i8 vector from { type (non_int ).__name__ } , "
1183
1189
"expected int."
1184
1190
)
1185
1191
data = _t .cast (tuple [int , ...], data )
0 commit comments