Skip to content

Commit

Permalink
Remove unnecessary generics from PyArray::from_raw_parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Sep 16, 2022
1 parent bf66005 commit 81b807c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
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<Dim = D>,
{
) -> &'py Self {
let container = PyClassInitializer::from(container)
.create_cell(py)
.expect("Failed to create slice container");
Expand Down
6 changes: 3 additions & 3 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<T: Element> IntoPyArray for Box<[T]> {

fn into_pyarray<'py>(self, py: Python<'py>) -> &'py PyArray<Self::Item, Self::Dim> {
let container = PySliceContainer::from(self);
let dims = [container.len];
let dims = Dim([container.len]);
let strides = [mem::size_of::<T>() 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,
Expand All @@ -66,7 +66,7 @@ impl<T: Element> IntoPyArray for Vec<T> {
type Dim = Ix1;

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

0 comments on commit 81b807c

Please sign in to comment.