Skip to content

Getter for dim in Shape #820

Description

@RolfStierle

For Shape, there is not getter for the dimension stored inside the structure. There was one, but now it is solely a comment (see below):

impl<D>Shape<D>whereD:Dimension,{// Return a reference to the dimension//pub fn dimension(&self) -> &D { &self.dim }/// Return the size of the shape in number of elementspubfnsize(&self) -> usize{self.dim.size()}}

Is there a possibility to extract the exact dimension stored inside Shape to use it to modify the dimensions of struct definitions (minimal example below) outside of the crate?

structTester<D:Dimension>{weight:Array<f64,D::Larger>,}implTester<Ix1>{fnnew<Sh>(shape:Sh,first_dim:usize) -> SelfwhereSh:ShapeBuilder<Dim = Ix1>,{let dim_in = shape.into_shape().dim;// This is not possible because the field `dim` is private. How can one obtain the dimension?let shape_new = Shape::from(Ix2(first_dim, dim[0]));let weight = Array::<f64,Ix2>::zeros(new);// ... modify `weight` ...Self{ weight }}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions