Skip to content

Commit b174540

Browse files
committed
Remove PyUFuncModule in favour of PyUFuncModule
1 parent e9ab6bd commit b174540

File tree

5 files changed

+384
-385
lines changed

5 files changed

+384
-385
lines changed

src/array.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Safe interface for NumPy ndarray
22
33
use ndarray::*;
4-
use npyffi::{self, PyArrayAPI};
4+
use npyffi::{self, PY_ARRAY_API};
55
use pyo3::*;
66
use std::marker::PhantomData;
77
use std::os::raw::c_void;
@@ -15,7 +15,7 @@ pub struct PyArray<T>(PyObject, PhantomData<T>);
1515

1616
pyobject_native_type_convert!(
1717
PyArray<T>,
18-
*npyffi::PyArrayAPI.get_type_object(npyffi::ArrayType::PyArray_Type),
18+
*npyffi::PY_ARRAY_API.get_type_object(npyffi::ArrayType::PyArray_Type),
1919
npyffi::PyArray_Check,
2020
T
2121
);
@@ -364,8 +364,8 @@ impl<T: TypeNum> PyArray<T> {
364364
data: *mut c_void,
365365
) -> &'py Self {
366366
let dims: Vec<_> = dims.iter().map(|d| *d as npy_intp).collect();
367-
let ptr = PyArrayAPI.PyArray_New(
368-
PyArrayAPI.get_type_object(npyffi::ArrayType::PyArray_Type),
367+
let ptr = PY_ARRAY_API.PyArray_New(
368+
PY_ARRAY_API.get_type_object(npyffi::ArrayType::PyArray_Type),
369369
dims.len() as i32,
370370
dims.as_ptr() as *mut npy_intp,
371371
T::typenum_default(),
@@ -414,8 +414,8 @@ impl<T: TypeNum> PyArray<T> {
414414
pub fn zeros<'py>(py: Python<'py>, dims: &[usize], is_fortran: bool) -> &'py Self {
415415
let dims: Vec<npy_intp> = dims.iter().map(|d| *d as npy_intp).collect();
416416
unsafe {
417-
let descr = PyArrayAPI.PyArray_DescrFromType(T::typenum_default());
418-
let ptr = PyArrayAPI.PyArray_Zeros(
417+
let descr = PY_ARRAY_API.PyArray_DescrFromType(T::typenum_default());
418+
let ptr = PY_ARRAY_API.PyArray_Zeros(
419419
dims.len() as i32,
420420
dims.as_ptr() as *mut npy_intp,
421421
descr,
@@ -443,7 +443,7 @@ impl<T: TypeNum> PyArray<T> {
443443
/// # }
444444
pub fn arange<'py>(py: Python<'py>, start: f64, stop: f64, step: f64) -> &'py Self {
445445
unsafe {
446-
let ptr = PyArrayAPI.PyArray_Arange(start, stop, step, T::typenum_default());
446+
let ptr = PY_ARRAY_API.PyArray_Arange(start, stop, step, T::typenum_default());
447447
Self::from_owned_ptr(py, ptr)
448448
}
449449
}
@@ -463,7 +463,7 @@ impl<T: TypeNum> PyArray<T> {
463463
pub fn copy_to<U: TypeNum>(&self, other: &mut PyArray<U>) -> Result<(), ArrayCastError> {
464464
let self_ptr = self.as_array_ptr();
465465
let other_ptr = other.as_array_ptr();
466-
let result = unsafe { PyArrayAPI.PyArray_CopyInto(other_ptr, self_ptr) };
466+
let result = unsafe { PY_ARRAY_API.PyArray_CopyInto(other_ptr, self_ptr) };
467467
if result == -1 {
468468
Err(ArrayCastError::Numpy {
469469
from: T::npy_data_type(),
@@ -489,7 +489,7 @@ impl<T: TypeNum> PyArray<T> {
489489
pub fn move_to<U: TypeNum>(&self, other: &mut PyArray<U>) -> Result<(), ArrayCastError> {
490490
let self_ptr = self.as_array_ptr();
491491
let other_ptr = other.as_array_ptr();
492-
let result = unsafe { PyArrayAPI.PyArray_MoveInto(other_ptr, self_ptr) };
492+
let result = unsafe { PY_ARRAY_API.PyArray_MoveInto(other_ptr, self_ptr) };
493493
if result == -1 {
494494
Err(ArrayCastError::Numpy {
495495
from: T::npy_data_type(),
@@ -517,8 +517,8 @@ impl<T: TypeNum> PyArray<T> {
517517
is_fortran: bool,
518518
) -> Result<&'py PyArray<U>, ArrayCastError> {
519519
let ptr = unsafe {
520-
let descr = PyArrayAPI.PyArray_DescrFromType(U::typenum_default());
521-
PyArrayAPI.PyArray_CastToType(
520+
let descr = PY_ARRAY_API.PyArray_DescrFromType(U::typenum_default());
521+
PY_ARRAY_API.PyArray_CastToType(
522522
self.as_array_ptr(),
523523
descr,
524524
if is_fortran { -1 } else { 0 },

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ pub mod types;
4747
pub use array::PyArray;
4848
pub use convert::IntoPyArray;
4949
pub use error::*;
50-
pub use npyffi::{PyArrayAPI, PyUFuncModule};
50+
pub use npyffi::{PY_ARRAY_API, PY_UFUNC_API};
5151
pub use types::*;

0 commit comments

Comments
 (0)