pub enum ArraysD {
Show 20 variants
Bool(ArrayD<bool>),
I8(ArrayD<i8>),
I16(ArrayD<i16>),
I32(ArrayD<i32>),
I64(ArrayD<i64>),
U8(ArrayD<u8>),
U16(ArrayD<u16>),
U32(ArrayD<u32>),
U64(ArrayD<u64>),
F16(ArrayD<f16>),
F32(ArrayD<f32>),
F64(ArrayD<f64>),
C64(ArrayD<C32>),
C128(ArrayD<C64>),
Object(ArrayD<PyObjectRef>),
Str {
itemsize_chars: u32,
data: ArrayD<String>,
},
Bytes {
itemsize: u32,
data: ArrayD<Vec<u8>>,
},
Datetime64 {
unit: TimeUnit,
data: ArrayD<i64>,
},
Timedelta64 {
unit: TimeUnit,
data: ArrayD<i64>,
},
Void {
layout: Arc<StructLayout>,
data: ArrayD<Vec<u8>>,
},
}Expand description
A dynamic-shape array tagged with its numpy dtype.
Numeric variants hold an ArrayD<T> of fixed-width copy element types.
Non-numeric variants carry their own metadata (itemsize, unit, layout):
Object:ArrayD<PyObjectRef>— refcounted Python references per cell.Str { itemsize_chars, data }: ASCII / UCS-4 stored as a singleStringper element (padded toitemsize_charscode points logically; we just truncate-on-store and never read past).Bytes { itemsize, data }:ArrayD<Vec<u8>>, each Vec of lengthitemsize.Datetime64/Timedelta64:ArrayD<i64>(the raw unit-count) plus the resolution unit.Void { layout, data }:ArrayD<Vec<u8>>(each element of sizelayout.itemsize), plus anArc<StructLayout>describing fields.
Variants§
Bool(ArrayD<bool>)
I8(ArrayD<i8>)
I16(ArrayD<i16>)
I32(ArrayD<i32>)
I64(ArrayD<i64>)
U8(ArrayD<u8>)
U16(ArrayD<u16>)
U32(ArrayD<u32>)
U64(ArrayD<u64>)
F16(ArrayD<f16>)
F32(ArrayD<f32>)
F64(ArrayD<f64>)
C64(ArrayD<C32>)
C128(ArrayD<C64>)
Object(ArrayD<PyObjectRef>)
Str
Bytes
Datetime64
Timedelta64
Void
Implementations§
Source§impl ArraysD
impl ArraysD
pub fn dtype(&self) -> DType
pub fn shape(&self) -> &[usize]
pub fn ndim(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn raw_dim(&self) -> IxDyn
Sourcepub fn cast(&self, target: DType) -> ArraysD
pub fn cast(&self, target: DType) -> ArraysD
Return a new array of the requested dtype, with values cast.
This is ndarray.astype(new_dtype).
Sourcepub fn cast_cow(&self, target: DType) -> Cow<'_, ArraysD>
pub fn cast_cow(&self, target: DType) -> Cow<'_, ArraysD>
Like [cast] but borrows the original storage when no conversion is
needed. Use this from the hot binary-op paths so we don’t clone the
underlying buffer just to discover the dtypes already match.
Sourcepub fn as_array<T: ArrayElement>(&self) -> Option<&ArrayD<T>>
pub fn as_array<T: ArrayElement>(&self) -> Option<&ArrayD<T>>
Return &ArrayD<T> if the stored variant matches T, otherwise
None. The ArrayElement trait below is impl’d for every numpy
element type, so this works generically:
if let Some(a) = arrs.as_array::<f64>() { /* use &ArrayD<f64> */ }Sourcepub fn as_array_mut<T: ArrayElement>(&mut self) -> Option<&mut ArrayD<T>>
pub fn as_array_mut<T: ArrayElement>(&mut self) -> Option<&mut ArrayD<T>>
Mutable variant of as_array.
Sourcepub fn into_array<T: ArrayElement>(self) -> Result<ArrayD<T>, ArraysD>
pub fn into_array<T: ArrayElement>(self) -> Result<ArrayD<T>, ArraysD>
Consume self and return the inner ArrayD<T> if the variant
matches, otherwise hand back the original ArraysD unchanged.
Sourcepub fn as_bool(&self) -> Option<&ArrayD<bool>>
pub fn as_bool(&self) -> Option<&ArrayD<bool>>
Per-dtype shortcut accessors — equivalent to as_array::<T>() but
don’t require a turbofish.
pub fn as_i8(&self) -> Option<&ArrayD<i8>>
pub fn as_i16(&self) -> Option<&ArrayD<i16>>
pub fn as_i32(&self) -> Option<&ArrayD<i32>>
pub fn as_i64(&self) -> Option<&ArrayD<i64>>
pub fn as_u8(&self) -> Option<&ArrayD<u8>>
pub fn as_u16(&self) -> Option<&ArrayD<u16>>
pub fn as_u32(&self) -> Option<&ArrayD<u32>>
pub fn as_u64(&self) -> Option<&ArrayD<u64>>
pub fn as_f16(&self) -> Option<&ArrayD<f16>>
pub fn as_f32(&self) -> Option<&ArrayD<f32>>
pub fn as_f64(&self) -> Option<&ArrayD<f64>>
pub fn as_c64(&self) -> Option<&ArrayD<C32>>
pub fn as_c128(&self) -> Option<&ArrayD<C64>>
pub fn as_bool_mut(&mut self) -> Option<&mut ArrayD<bool>>
pub fn as_i8_mut(&mut self) -> Option<&mut ArrayD<i8>>
pub fn as_i16_mut(&mut self) -> Option<&mut ArrayD<i16>>
pub fn as_i32_mut(&mut self) -> Option<&mut ArrayD<i32>>
pub fn as_i64_mut(&mut self) -> Option<&mut ArrayD<i64>>
pub fn as_u8_mut(&mut self) -> Option<&mut ArrayD<u8>>
pub fn as_u16_mut(&mut self) -> Option<&mut ArrayD<u16>>
pub fn as_u32_mut(&mut self) -> Option<&mut ArrayD<u32>>
pub fn as_u64_mut(&mut self) -> Option<&mut ArrayD<u64>>
pub fn as_f16_mut(&mut self) -> Option<&mut ArrayD<f16>>
pub fn as_f32_mut(&mut self) -> Option<&mut ArrayD<f32>>
pub fn as_f64_mut(&mut self) -> Option<&mut ArrayD<f64>>
pub fn as_c64_mut(&mut self) -> Option<&mut ArrayD<C32>>
pub fn as_c128_mut(&mut self) -> Option<&mut ArrayD<C64>>
Trait Implementations§
Source§impl CoerceArray for ArraysD
impl CoerceArray for ArraysD
Source§fn coerce<T: ArrayElement>(&self) -> ArrayD<T>
fn coerce<T: ArrayElement>(&self) -> ArrayD<T>
ArrayD<T> containing the same elements as self, casting
to T if the underlying dtype differs.Source§fn try_borrow_as<T: ArrayElement>(&self) -> Option<&ArrayD<T>>
fn try_borrow_as<T: ArrayElement>(&self) -> Option<&ArrayD<T>>
&ArrayD<T> only if the underlying dtype already matches.Source§fn into_coerced<T: ArrayElement>(self) -> ArrayD<T>
fn into_coerced<T: ArrayElement>(self) -> ArrayD<T>
self and return ArrayD<T>, casting if necessary.Auto Trait Implementations§
impl !RefUnwindSafe for ArraysD
impl !Send for ArraysD
impl !Sync for ArraysD
impl !UnwindSafe for ArraysD
impl Freeze for ArraysD
impl Unpin for ArraysD
impl UnsafeUnpin for ArraysD
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more