Skip to content

Commit

Permalink
Merge pull request #5 from espdev/fix-into-shape
Browse files Browse the repository at this point in the history
Use into_shape instead of into_shape_with_order to fix memory layout errors
  • Loading branch information
espdev authored Sep 30, 2024
2 parents d7c3f99 + bfd4617 commit 7b1e2af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ndarrayext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn to_2d<'a, T: 'a, D, I>(data: I, axis: Axis) -> Result<ArrayView2<'a, T>>
let axis_size = shape[axis.0];
let new_shape = [numel / axis_size, axis_size];

match data_view.permuted_axes(axes).into_shape_with_order(new_shape) {
match data_view.permuted_axes(axes).into_shape(new_shape) {
Ok(view_2d) => Ok(view_2d),
Err(error) => Err(
ReshapeTo2d {
Expand All @@ -68,7 +68,7 @@ pub fn to_2d_simple<'a, T: 'a, D>(data: ArrayView<'a, T, D>) -> Result<ArrayView
let shape = data.shape().to_vec();
let new_shape = [shape[0..(ndim - 1)].iter().product(), shape[ndim - 1]];

match data.into_shape_with_order(new_shape) {
match data.into_shape(new_shape) {
Ok(data_2d) => Ok(data_2d),
Err(error) => Err(
ReshapeTo2d {
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn from_2d<'a, T: 'a, D, S, I>(data: I, shape: S, axis: Axis) -> Result<Arra
let new_shape: D = dim_from_vec(ndim, new_shape_vec.clone());
let data_view = data.into();

match data_view.into_shape_with_order(new_shape) {
match data_view.into_shape(new_shape) {
Ok(view_nd) => {
let mut axes_tmp: Vec<usize> = (0..ndim).collect();
let end_axis = axes_tmp.pop().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/ndg/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a, T, D> NdGridSpline<'a, T, D>
let shape: D = dim_from_vec(self.ndim, coeffs_shape);

coeffs_2d
.into_shape_with_order(shape).unwrap()
.into_shape(shape).unwrap()
.permuted_axes(permuted_axes.clone())
.to_owned()
};
Expand Down
2 changes: 1 addition & 1 deletion src/ndg/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
let new_shape: D = dim_from_vec(ndim, coeffs_shape);

spline.coeffs()
.into_shape_with_order(new_shape).unwrap()
.into_shape(new_shape).unwrap()
.permuted_axes(permuted_axes.clone())
.to_owned()
};
Expand Down

0 comments on commit 7b1e2af

Please sign in to comment.