You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 }}}
Makes sense. Some redesign is needed. Right now, these are only designed for argument conversion for the constructors, and are not intended to be modified like this.
Activity
bluss commentedon May 21, 2020
Makes sense. Some redesign is needed. Right now, these are only designed for argument conversion for the constructors, and are not intended to be modified like this.
RolfStierle commentedon May 30, 2020
Thank you for you reply.
stokhos commentedon Apr 8, 2021
Is anyone working on this. If not I'd like to work on this issue. @bluss @jturner314
bluss commentedon Apr 8, 2021
Feel free to add this accessor in a simple way. Shape/StrideShape needs redesign but I'd like to give input on that another time