Skip to main content

ArraysD

Enum ArraysD 

Source
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 single String per element (padded to itemsize_chars code points logically; we just truncate-on-store and never read past).
  • Bytes { itemsize, data }: ArrayD<Vec<u8>>, each Vec of length itemsize.
  • Datetime64/Timedelta64: ArrayD<i64> (the raw unit-count) plus the resolution unit.
  • Void { layout, data }: ArrayD<Vec<u8>> (each element of size layout.itemsize), plus an Arc<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

Fields

§itemsize_chars: u32
§

Bytes

Fields

§itemsize: u32
§data: ArrayD<Vec<u8>>
§

Datetime64

Fields

§data: ArrayD<i64>
§

Timedelta64

Fields

§data: ArrayD<i64>
§

Void

Fields

§data: ArrayD<Vec<u8>>

Implementations§

Source§

impl ArraysD

Source

pub fn dtype(&self) -> DType

Source

pub fn shape(&self) -> &[usize]

Source

pub fn ndim(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn raw_dim(&self) -> IxDyn

Source

pub fn nbytes(&self) -> usize

Number-of-bytes the data takes (excluding headers).

Source

pub fn cast(&self, target: DType) -> ArraysD

Return a new array of the requested dtype, with values cast. This is ndarray.astype(new_dtype).

Source

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.

Source

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> */ }
Source

pub fn as_array_mut<T: ArrayElement>(&mut self) -> Option<&mut ArrayD<T>>

Mutable variant of as_array.

Source

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.

Source

pub fn as_bool(&self) -> Option<&ArrayD<bool>>

Per-dtype shortcut accessors — equivalent to as_array::<T>() but don’t require a turbofish.

Source

pub fn as_i8(&self) -> Option<&ArrayD<i8>>

Source

pub fn as_i16(&self) -> Option<&ArrayD<i16>>

Source

pub fn as_i32(&self) -> Option<&ArrayD<i32>>

Source

pub fn as_i64(&self) -> Option<&ArrayD<i64>>

Source

pub fn as_u8(&self) -> Option<&ArrayD<u8>>

Source

pub fn as_u16(&self) -> Option<&ArrayD<u16>>

Source

pub fn as_u32(&self) -> Option<&ArrayD<u32>>

Source

pub fn as_u64(&self) -> Option<&ArrayD<u64>>

Source

pub fn as_f16(&self) -> Option<&ArrayD<f16>>

Source

pub fn as_f32(&self) -> Option<&ArrayD<f32>>

Source

pub fn as_f64(&self) -> Option<&ArrayD<f64>>

Source

pub fn as_c64(&self) -> Option<&ArrayD<C32>>

Source

pub fn as_c128(&self) -> Option<&ArrayD<C64>>

Source

pub fn as_bool_mut(&mut self) -> Option<&mut ArrayD<bool>>

Source

pub fn as_i8_mut(&mut self) -> Option<&mut ArrayD<i8>>

Source

pub fn as_i16_mut(&mut self) -> Option<&mut ArrayD<i16>>

Source

pub fn as_i32_mut(&mut self) -> Option<&mut ArrayD<i32>>

Source

pub fn as_i64_mut(&mut self) -> Option<&mut ArrayD<i64>>

Source

pub fn as_u8_mut(&mut self) -> Option<&mut ArrayD<u8>>

Source

pub fn as_u16_mut(&mut self) -> Option<&mut ArrayD<u16>>

Source

pub fn as_u32_mut(&mut self) -> Option<&mut ArrayD<u32>>

Source

pub fn as_u64_mut(&mut self) -> Option<&mut ArrayD<u64>>

Source

pub fn as_f16_mut(&mut self) -> Option<&mut ArrayD<f16>>

Source

pub fn as_f32_mut(&mut self) -> Option<&mut ArrayD<f32>>

Source

pub fn as_f64_mut(&mut self) -> Option<&mut ArrayD<f64>>

Source

pub fn as_c64_mut(&mut self) -> Option<&mut ArrayD<C32>>

Source

pub fn as_c128_mut(&mut self) -> Option<&mut ArrayD<C64>>

Trait Implementations§

Source§

impl AsMut<ArraysD> for PyNdArray

Source§

fn as_mut(&mut self) -> &mut ArraysD

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<ArraysD> for PyNdArray

Source§

fn as_ref(&self) -> &ArraysD

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ArraysD

Source§

fn clone(&self) -> ArraysD

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CoerceArray for ArraysD

Source§

fn coerce<T: ArrayElement>(&self) -> ArrayD<T>

Return an 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>>

Borrow &ArrayD<T> only if the underlying dtype already matches.
Source§

fn into_coerced<T: ArrayElement>(self) -> ArrayD<T>

Consume self and return ArrayD<T>, casting if necessary.
Source§

impl Debug for ArraysD

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ArrayBase<OwnedRepr<Complex<f32>>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<C32>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<Complex<f64>>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<C64>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<bool>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<bool>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<f16>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<f16>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<f32>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<f32>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<f64>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<f64>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<i8>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<i8>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<i16>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<i16>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<i32>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<i32>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<i64>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<i64>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<u8>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<u8>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<u16>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<u16>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<u32>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<u32>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArrayBase<OwnedRepr<u64>, Dim<IxDynImpl>>> for ArraysD

Source§

fn from(a: ArrayD<u64>) -> ArraysD

Converts to this type from the input type.
Source§

impl From<ArraysD> for PyNdArray

Source§

fn from(inner: ArraysD) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<ArraysD> for ArrayD<bool>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<i8>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<i16>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<i32>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<i64>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<u8>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<u16>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<u32>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<u64>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<f16>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<f32>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<f64>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<C32>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.
Source§

impl TryFrom<ArraysD> for ArrayD<C64>

Source§

type Error = ArraysD

The type returned in the event of a conversion error.
Source§

fn try_from(a: ArraysD) -> Result<Self, ArraysD>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T> PyThreadingConstraint for T

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U