Skip to content

Commit d93f8b7

Browse files
author
Pavel Potoček
committed
Fix a panic when calling to_owned_array on a PyArrayDyn
1 parent 9400e3a commit d93f8b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
274274
}
275275

276276
fn ndarray_shape(&self) -> StrideShape<D> {
277-
// FIXME may be done more simply
278277
let shape: Shape<_> = Dim(self.dims()).into();
279-
let mut st = D::default();
280278
let size = mem::size_of::<T>();
281-
for (i, &s) in self.strides().iter().enumerate() {
282-
st[i] = s as usize / size;
283-
}
279+
let st = D::from_dimension(&Dim(
280+
self.strides().iter()
281+
.map(|&s| s as usize / size)
282+
.collect::<Vec<_>>()
283+
)).unwrap();
284284
shape.strides(st)
285285
}
286286

0 commit comments

Comments
 (0)