pub struct Dimensions { /* private fields */ }Expand description
An ordered list of named axes, C-order. Cheap to clone.
Rank 0 (no axes) describes a scalar: one logical element.
Implementations§
Source§impl Dimensions
impl Dimensions
Sourcepub fn try_new(
dims: impl IntoIterator<Item = impl Into<Dimension>>,
) -> Result<Self>
pub fn try_new( dims: impl IntoIterator<Item = impl Into<Dimension>>, ) -> Result<Self>
Create dimensions, validating that axis names are non-empty and unique.
Sourcepub fn num_elements(&self) -> usize
pub fn num_elements(&self) -> usize
Total number of logical elements (1 for a scalar, 0 if any axis is empty).
Sourcepub fn checked_num_elements(&self) -> Option<usize>
pub fn checked_num_elements(&self) -> Option<usize>
Like Self::num_elements, but None on usize overflow.
Sourcepub fn axis(&self, name: &str) -> Result<usize>
pub fn axis(&self, name: &str) -> Result<usize>
The axis of name, or an error that names the dimensions.
Sourcepub fn broadcast(all: &[&Dimensions]) -> Result<Dimensions>
pub fn broadcast(all: &[&Dimensions]) -> Result<Dimensions>
The broadcast result of several dimension sets, xarray style.
Axes align by name. The order follows the first appearance of each name. Sizes must be equal, or one of them must be 1.
Sourcepub fn check_broadcast_to(&self, target: &Dimensions) -> Result<()>
pub fn check_broadcast_to(&self, target: &Dimensions) -> Result<()>
Fails when an array of these dimensions cannot broadcast onto target:
each axis must be in target, with the same size or with size 1.
Trait Implementations§
Source§impl Clone for Dimensions
impl Clone for Dimensions
Source§impl Debug for Dimensions
impl Debug for Dimensions
Source§impl Default for Dimensions
impl Default for Dimensions
Source§impl Display for Dimensions
impl Display for Dimensions
impl Eq for Dimensions
Source§impl Hash for Dimensions
impl Hash for Dimensions
Source§impl<'a> IntoIterator for &'a Dimensions
impl<'a> IntoIterator for &'a Dimensions
Source§impl PartialEq for Dimensions
impl PartialEq for Dimensions
impl StructuralPartialEq for Dimensions
Auto Trait Implementations§
impl Freeze for Dimensions
impl RefUnwindSafe for Dimensions
impl Send for Dimensions
impl Sync for Dimensions
impl Unpin for Dimensions
impl UnsafeUnpin for Dimensions
impl UnwindSafe for Dimensions
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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 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> ⓘ
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