pub trait ToNdarray<T> {
    fn to_ndarray(&self, t: Type) -> Result<ArrayD<T>>;
}

Required Methods

Implementors

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u64

Examples

let a = array![[false, true], [true, false]].into_dyn();
let v = Value::from_ndarray(a.clone(), BIT).unwrap();
let converted = ToNdarray::<bool>::to_ndarray(&v,array_type(vec![2, 2], BIT)).unwrap();
assert_eq!(converted, a);

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i8.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i8

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i8>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i8, 123i32 as i8], [-456i32 as i8, 456i32 as i8]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i16.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i16

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i16>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i16, 123i32 as i16], [-456i32 as i16, 456i32 as i16]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i32.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i32

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i32>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32, 123i32], [-456i32, 456i32]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i64

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i64>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u32 as i64, 123i32 as u32 as i64], [-456i32 as u32 as i64, 456i32 as u32 as i64]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u8.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u8

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u8>::to_ndarray(&v, array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u8, 123i32 as u8], [-456i32 as u8, 456i32 as u8]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u16.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u16

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u16>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u16, 123i32 as u16], [-456i32 as u16, 456i32 as u16]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u32.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u32

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u32>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u32, 123i32 as u32], [-456i32 as u32, 456i32 as u32]].into_dyn());

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u64

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u64>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u32 as u64, 123i32 as u32 as u64], [-456i32 as u32 as u64, 456i32 as u32 as u64]].into_dyn());