From 81b807c9014be13399abccdbbf08a165bf2222ae Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Fri, 16 Sep 2022 16:34:43 +0200 Subject: [PATCH] Remove unnecessary generics from PyArray::from_raw_parts. --- src/array.rs | 9 +++------ src/convert.rs | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/array.rs b/src/array.rs index 9415180ae..1128b4275 100644 --- a/src/array.rs +++ b/src/array.rs @@ -512,16 +512,13 @@ impl PyArray { Self::from_owned_ptr(py, ptr) } - pub(crate) unsafe fn from_raw_parts<'py, ID>( + pub(crate) unsafe fn from_raw_parts<'py>( py: Python<'py>, - dims: ID, + dims: D, strides: *const npy_intp, data_ptr: *const T, container: PySliceContainer, - ) -> &'py Self - where - ID: IntoDimension, - { + ) -> &'py Self { let container = PyClassInitializer::from(container) .create_cell(py) .expect("Failed to create slice container"); diff --git a/src/convert.rs b/src/convert.rs index e9c2c5dbb..10d19693a 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -2,7 +2,7 @@ use std::{mem, os::raw::c_int, ptr}; -use ndarray::{ArrayBase, Data, Dimension, IntoDimension, Ix1, OwnedRepr}; +use ndarray::{ArrayBase, Data, Dim, Dimension, IntoDimension, Ix1, OwnedRepr}; use pyo3::Python; use crate::array::PyArray; @@ -51,7 +51,7 @@ impl IntoPyArray for Box<[T]> { fn into_pyarray<'py>(self, py: Python<'py>) -> &'py PyArray { let container = PySliceContainer::from(self); - let dims = [container.len]; + let dims = Dim([container.len]); let strides = [mem::size_of::() as npy_intp]; // The data pointer is derived only after dissolving `Box` into `PySliceContainer` // to avoid unsound aliasing of Box<[T]> which is currently noalias, @@ -66,7 +66,7 @@ impl IntoPyArray for Vec { type Dim = Ix1; fn into_pyarray<'py>(mut self, py: Python<'py>) -> &'py PyArray { - let dims = [self.len()]; + let dims = Dim([self.len()]); let strides = [mem::size_of::() as npy_intp]; let data_ptr = self.as_mut_ptr(); unsafe {