@@ -6,9 +6,11 @@ use std::cmp::Ordering;
66use std:: fmt:: { Debug , Display , Formatter } ;
77use std:: ops:: { Add , Sub } ;
88
9- use num_traits:: { CheckedAdd , CheckedDiv , CheckedMul , CheckedSub , FromPrimitive } ;
9+ use num_traits:: { CheckedAdd , CheckedDiv , CheckedMul , CheckedSub } ;
1010use vortex_dtype:: half:: f16;
11- use vortex_dtype:: { DType , NativePType , Nullability , PType , match_each_native_ptype} ;
11+ use vortex_dtype:: {
12+ DType , FromPrimitiveOrF16 , NativePType , Nullability , PType , match_each_native_ptype,
13+ } ;
1214use vortex_error:: { VortexError , VortexExpect , VortexResult , vortex_err, vortex_panic} ;
1315
1416use crate :: pvalue:: { CoercePValue , PValue } ;
@@ -104,7 +106,7 @@ impl<'a> PrimitiveScalar<'a> {
104106 /// # Panics
105107 ///
106108 /// Panics if the primitive type of this scalar does not match the requested type.
107- pub fn typed_value < T : NativePType + TryFrom < PValue , Error = VortexError > > ( & self ) -> Option < T > {
109+ pub fn typed_value < T : NativePType > ( & self ) -> Option < T > {
108110 assert_eq ! (
109111 self . ptype,
110112 T :: PTYPE ,
@@ -215,52 +217,6 @@ impl<'a> PrimitiveScalar<'a> {
215217 }
216218}
217219
218- /// A trait for types that can be created from primitive values, including f16.
219- ///
220- /// This extends the `FromPrimitive` trait to also support conversion from f16 values.
221- pub trait FromPrimitiveOrF16 : FromPrimitive {
222- /// Converts an f16 value to this type, returning None if the conversion fails.
223- fn from_f16 ( v : f16 ) -> Option < Self > ;
224- }
225-
226- macro_rules! from_primitive_or_f16_for_non_floating_point {
227- ( $T: ty) => {
228- impl FromPrimitiveOrF16 for $T {
229- fn from_f16( _: f16) -> Option <Self > {
230- None
231- }
232- }
233- } ;
234- }
235-
236- from_primitive_or_f16_for_non_floating_point ! ( usize ) ;
237- from_primitive_or_f16_for_non_floating_point ! ( u8 ) ;
238- from_primitive_or_f16_for_non_floating_point ! ( u16 ) ;
239- from_primitive_or_f16_for_non_floating_point ! ( u32 ) ;
240- from_primitive_or_f16_for_non_floating_point ! ( u64 ) ;
241- from_primitive_or_f16_for_non_floating_point ! ( i8 ) ;
242- from_primitive_or_f16_for_non_floating_point ! ( i16 ) ;
243- from_primitive_or_f16_for_non_floating_point ! ( i32 ) ;
244- from_primitive_or_f16_for_non_floating_point ! ( i64 ) ;
245-
246- impl FromPrimitiveOrF16 for f16 {
247- fn from_f16 ( v : f16 ) -> Option < Self > {
248- Some ( v)
249- }
250- }
251-
252- impl FromPrimitiveOrF16 for f32 {
253- fn from_f16 ( v : f16 ) -> Option < Self > {
254- Some ( v. to_f32 ( ) )
255- }
256- }
257-
258- impl FromPrimitiveOrF16 for f64 {
259- fn from_f16 ( v : f16 ) -> Option < Self > {
260- Some ( v. to_f64 ( ) )
261- }
262- }
263-
264220impl < ' a > TryFrom < & ' a Scalar > for PrimitiveScalar < ' a > {
265221 type Error = VortexError ;
266222
0 commit comments