Enum numcodecs::AnyArrayBase

source ·
#[non_exhaustive]
pub enum AnyArrayBase<T: AnyRawData> { U8(ArrayBase<T::U8, IxDyn>), U16(ArrayBase<T::U16, IxDyn>), U32(ArrayBase<T::U32, IxDyn>), U64(ArrayBase<T::U64, IxDyn>), I8(ArrayBase<T::I8, IxDyn>), I16(ArrayBase<T::I16, IxDyn>), I32(ArrayBase<T::I32, IxDyn>), I64(ArrayBase<T::I64, IxDyn>), F32(ArrayBase<T::F32, IxDyn>), F64(ArrayBase<T::F64, IxDyn>), }
Expand description

Numeric n-dimensional arrays with dynamic shapes.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

Implementations§

source§

impl<T: AnyRawData> AnyArrayBase<T>

source

pub fn len(&self) -> usize

Returns the total number of elements in the array.

source

pub fn is_empty(&self) -> bool

Returns whether the array has any elements.

source

pub const fn dtype(&self) -> AnyArrayDType

Returns the dtype of the array.

source

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

Returns the shape of the array.

source

pub fn strides(&self) -> &[isize]

Return the strides of the array.

source

pub const fn as_typed<U: ArrayDType>( &self, ) -> Option<&ArrayBase<U::RawData<T>, IxDyn>>

Returns the U-typed array in Some(_) iff the dtype of U matches the dtype of this array. Returns None otherwise.

source

pub fn as_typed_mut<U: ArrayDType>( &mut self, ) -> Option<&mut ArrayBase<U::RawData<T>, IxDyn>>

Returns the U-typed array in Some(_) iff the dtype of U matches the dtype of this array. Returns None otherwise.

source§

impl<T: AnyRawData> AnyArrayBase<T>
where T::U8: Data, T::U16: Data, T::U32: Data, T::U64: Data, T::I8: Data, T::I16: Data, T::I32: Data, T::I64: Data, T::F32: Data, T::F64: Data,

source

pub fn view(&self) -> AnyArrayView<'_>

Returns a read-only view of the array.

source

pub fn cow(&self) -> AnyCowArray<'_>

Returns a copy-on-write view of the array.

source

pub fn into_owned(self) -> AnyArray

Turns the array into a uniquely owned array, cloning the array elements if necessary.

source

pub fn as_bytes(&self) -> Cow<'_, [u8]>

Returns the array’s data as a byte slice.

If the array is contiguous and in standard order, i.e. if the element order in memory corresponds to the logical order of the array’s elements, a view of the data is returned without cloning.

Otherwise, the data is cloned and put into standard order first.

source§

impl<T: AnyRawData> AnyArrayBase<T>
where T::U8: DataMut, T::U16: DataMut, T::U32: DataMut, T::U64: DataMut, T::I8: DataMut, T::I16: DataMut, T::I32: DataMut, T::I64: DataMut, T::F32: DataMut, T::F64: DataMut,

source

pub fn view_mut(&mut self) -> AnyArrayViewMut<'_>

Returns a read-write view of the array.

source

pub fn with_bytes_mut<O>(&mut self, with: impl FnOnce(&mut [u8]) -> O) -> O

Provides access to the array’s data as a mutable byte slice.

If the array is contiguous and in standard order, i.e. if the element order in memory corresponds to the logical order of the array’s elements, a mutable view of the data is returned without cloning.

Otherwise, the data is cloned and put into standard order first, and later copied back into the array.

source

pub fn assign<U: AnyRawData>( &mut self, src: &AnyArrayBase<U>, ) -> Result<(), AnyArrayAssignError>
where U::U8: Data, U::U16: Data, U::U32: Data, U::U64: Data, U::I8: Data, U::I16: Data, U::I32: Data, U::I64: Data, U::F32: Data, U::F64: Data,

Perform an elementwise assigment to self from src.

§Errors

Errors with

source§

impl AnyArrayBase<OwnedRepr<()>>

source

pub fn zeros(dtype: AnyArrayDType, shape: &[usize]) -> Self

Create an array with zeros of dtype and shape shape.

source

pub fn with_zeros_bytes<T>( dtype: AnyArrayDType, shape: &[usize], with: impl FnOnce(&mut [u8]) -> T, ) -> (Self, T)

Create an array with zeros of dtype and shape shape, and provide mutable access to the bytes of the array.

The array is created to be contiguous and in standard order, i.e. its element order in memory corresponds to the logical order of the array’s elements.

source

pub fn into_cow(self) -> AnyCowArray<'static>

Returns an owned copy-on-write array.

Trait Implementations§

source§

impl<T: AnyRawData> Clone for AnyArrayBase<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: AnyRawData> Debug for AnyArrayBase<T>
where T::U8: Data, T::U16: Data, T::U32: Data, T::U64: Data, T::I8: Data, T::I16: Data, T::I32: Data, T::I64: Data, T::F32: Data, T::F64: Data,

source§

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

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

impl<T: AnyRawData> PartialEq for AnyArrayBase<T>
where T::U8: Data, T::U16: Data, T::U32: Data, T::U64: Data, T::I8: Data, T::I16: Data, T::I32: Data, T::I64: Data, T::F32: Data, T::F64: Data,

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T> Freeze for AnyArrayBase<T>
where <T as AnyRawData>::U8: Freeze, <T as AnyRawData>::U16: Freeze, <T as AnyRawData>::U32: Freeze, <T as AnyRawData>::U64: Freeze, <T as AnyRawData>::I8: Freeze, <T as AnyRawData>::I16: Freeze, <T as AnyRawData>::I32: Freeze, <T as AnyRawData>::I64: Freeze, <T as AnyRawData>::F32: Freeze, <T as AnyRawData>::F64: Freeze,

§

impl<T> RefUnwindSafe for AnyArrayBase<T>

§

impl<T> Send for AnyArrayBase<T>
where <T as AnyRawData>::U8: Send + Data, <T as AnyRawData>::U16: Send + Data, <T as AnyRawData>::U32: Send + Data, <T as AnyRawData>::U64: Send + Data, <T as AnyRawData>::I8: Send + Data, <T as AnyRawData>::I16: Send + Data, <T as AnyRawData>::I32: Send + Data, <T as AnyRawData>::I64: Send + Data, <T as AnyRawData>::F32: Send + Data, <T as AnyRawData>::F64: Send + Data,

§

impl<T> Sync for AnyArrayBase<T>
where <T as AnyRawData>::U8: Sync + Data, <T as AnyRawData>::U16: Sync + Data, <T as AnyRawData>::U32: Sync + Data, <T as AnyRawData>::U64: Sync + Data, <T as AnyRawData>::I8: Sync + Data, <T as AnyRawData>::I16: Sync + Data, <T as AnyRawData>::I32: Sync + Data, <T as AnyRawData>::I64: Sync + Data, <T as AnyRawData>::F32: Sync + Data, <T as AnyRawData>::F64: Sync + Data,

§

impl<T> Unpin for AnyArrayBase<T>
where <T as AnyRawData>::U8: Unpin, <T as AnyRawData>::U16: Unpin, <T as AnyRawData>::U32: Unpin, <T as AnyRawData>::U64: Unpin, <T as AnyRawData>::I8: Unpin, <T as AnyRawData>::I16: Unpin, <T as AnyRawData>::I32: Unpin, <T as AnyRawData>::I64: Unpin, <T as AnyRawData>::F32: Unpin, <T as AnyRawData>::F64: Unpin,

§

impl<T> UnwindSafe for AnyArrayBase<T>

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.