Skip to main content

IntoShape

Trait IntoShape 

Source
pub trait IntoShape {
    // Required method
    fn into_shape(self) -> Result<Vec<usize>, FerrayError>;
}
Expand description

Convert a size argument into a concrete shape vector.

Implemented for:

  • usize — 1-D shape [n] (including n == 0 for an empty array)
  • &[usize] — arbitrary-rank shape
  • [usize; N] (any N, via const generics)
  • &[usize; N]
  • Vec<usize>

Zero-axis shapes (e.g. 0usize, [3, 0, 4]) are now permitted and produce an empty array, matching NumPy’s np.random.uniform(size=0) behaviour (#264, #455). The only rejected shape is a totally rank-empty &[], which would correspond to a 0-d scalar — that is not yet wired through the distribution machinery.

Required Methods§

Source

fn into_shape(self) -> Result<Vec<usize>, FerrayError>

Consume self and return the shape as a Vec<usize>.

§Errors

Returns FerrayError::InvalidValue if the resulting shape has zero rank (i.e. an empty shape slice).

Implementations on Foreign Types§

Source§

impl IntoShape for &Vec<usize>

Source§

impl IntoShape for &[usize]

Source§

impl IntoShape for usize

Source§

impl IntoShape for Vec<usize>

Source§

impl<const N: usize> IntoShape for &[usize; N]

Source§

impl<const N: usize> IntoShape for [usize; N]

Implementors§