Skip to content

Commit 81b807c

Browse files
committed
Remove unnecessary generics from PyArray::from_raw_parts.
1 parent bf66005 commit 81b807c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/array.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
512512
Self::from_owned_ptr(py, ptr)
513513
}
514514

515-
pub(crate) unsafe fn from_raw_parts<'py, ID>(
515+
pub(crate) unsafe fn from_raw_parts<'py>(
516516
py: Python<'py>,
517-
dims: ID,
517+
dims: D,
518518
strides: *const npy_intp,
519519
data_ptr: *const T,
520520
container: PySliceContainer,
521-
) -> &'py Self
522-
where
523-
ID: IntoDimension<Dim = D>,
524-
{
521+
) -> &'py Self {
525522
let container = PyClassInitializer::from(container)
526523
.create_cell(py)
527524
.expect("Failed to create slice container");

src/convert.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{mem, os::raw::c_int, ptr};
44

5-
use ndarray::{ArrayBase, Data, Dimension, IntoDimension, Ix1, OwnedRepr};
5+
use ndarray::{ArrayBase, Data, Dim, Dimension, IntoDimension, Ix1, OwnedRepr};
66
use pyo3::Python;
77

88
use crate::array::PyArray;
@@ -51,7 +51,7 @@ impl<T: Element> IntoPyArray for Box<[T]> {
5151

5252
fn into_pyarray<'py>(self, py: Python<'py>) -> &'py PyArray<Self::Item, Self::Dim> {
5353
let container = PySliceContainer::from(self);
54-
let dims = [container.len];
54+
let dims = Dim([container.len]);
5555
let strides = [mem::size_of::<T>() as npy_intp];
5656
// The data pointer is derived only after dissolving `Box` into `PySliceContainer`
5757
// to avoid unsound aliasing of Box<[T]> which is currently noalias,
@@ -66,7 +66,7 @@ impl<T: Element> IntoPyArray for Vec<T> {
6666
type Dim = Ix1;
6767

6868
fn into_pyarray<'py>(mut self, py: Python<'py>) -> &'py PyArray<Self::Item, Self::Dim> {
69-
let dims = [self.len()];
69+
let dims = Dim([self.len()]);
7070
let strides = [mem::size_of::<T>() as npy_intp];
7171
let data_ptr = self.as_mut_ptr();
7272
unsafe {

0 commit comments

Comments
 (0)