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
So first of all, I'm quite new to Rust, so my apologies if this is a stupid thing to do.
I'm trying append multiple ArrayView1-rows to an Array2. In order to do that, I have to transform the ArrayView1-slices to ArrayView2. However, this works only if the slice is not reversed, see following code snippet:
let mut result: Array2<i32> = Array::zeros((0, 4));
let arr: Array1<i32> = Array::from(vec![1,2,3,4]);
let slice: ArrayView1<i32> = arr.slice(s![..;1]);
// This works
let slice: ArrayView2<i32> = slice.into_shape((1, 4)).unwrap();
result.append(Axis(0), slice);
let slice_rev: ArrayView1<i32> = arr.slice(s![..;-1]);
// This fails with ShapeError/IncompatibleLayout: incompatible memory layout
let slice_rev: ArrayView2<i32> = slice_rev.into_shape((1, 4)).unwrap();
result.append(Axis(0), slice_rev);
So could someone point out to me, why this is failing? What am I doing wrong here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So first of all, I'm quite new to Rust, so my apologies if this is a stupid thing to do.
I'm trying append multiple
ArrayView1
-rows to anArray2
. In order to do that, I have to transform theArrayView1
-slices toArrayView2
. However, this works only if the slice is not reversed, see following code snippet:So could someone point out to me, why this is failing? What am I doing wrong here?
Thanks and best regards
Beta Was this translation helpful? Give feedback.
All reactions