From 3b29109b51ac3b7d4b515a06ef1c0659c9b95dab Mon Sep 17 00:00:00 2001 From: Bas Schoenmaeckers Date: Wed, 14 May 2025 10:54:12 +0200 Subject: [PATCH] update `pyo3` to 0.25 --- Cargo.toml | 8 +-- examples/linalg/Cargo.toml | 2 +- examples/parallel/Cargo.toml | 2 +- examples/simple/Cargo.toml | 2 +- src/array.rs | 123 ----------------------------------- src/convert.rs | 17 ----- src/dtype.rs | 45 +------------ src/lib.rs | 19 ------ src/sum_products.rs | 56 ---------------- 9 files changed, 10 insertions(+), 264 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 07a065d72..d935627d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "numpy" -version = "0.24.0" +version = "0.25.0" authors = [ "The rust-numpy Project Developers", "PyO3 Project and Contributors " @@ -22,15 +22,15 @@ num-complex = ">= 0.2, < 0.5" num-integer = "0.1" num-traits = "0.2" ndarray = ">= 0.15, < 0.17" -pyo3 = { version = "0.24.1", default-features = false, features = ["macros"] } +pyo3 = { version = "0.25.0", default-features = false, features = ["macros"] } rustc-hash = "2.0" [dev-dependencies] -pyo3 = { version = "0.24", default-features = false, features = ["auto-initialize"] } +pyo3 = { version = "0.25", default-features = false, features = ["auto-initialize"] } nalgebra = { version = ">=0.30, <0.34", default-features = false, features = ["std"] } [build-dependencies] -pyo3-build-config = { version = "0.24", features = ["resolve-config"] } +pyo3-build-config = { version = "0.25", features = ["resolve-config"] } [package.metadata.docs.rs] all-features = true diff --git a/examples/linalg/Cargo.toml b/examples/linalg/Cargo.toml index 14bcf7d40..b80adcfaa 100644 --- a/examples/linalg/Cargo.toml +++ b/examples/linalg/Cargo.toml @@ -9,7 +9,7 @@ name = "rust_linalg" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.24.1", features = ["extension-module"] } +pyo3 = { version = "0.25.0", features = ["extension-module"] } numpy = { path = "../.." } ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] } diff --git a/examples/parallel/Cargo.toml b/examples/parallel/Cargo.toml index 925deaded..2b53eca47 100644 --- a/examples/parallel/Cargo.toml +++ b/examples/parallel/Cargo.toml @@ -9,7 +9,7 @@ name = "rust_parallel" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.24.0", features = ["extension-module", "multiple-pymethods"] } +pyo3 = { version = "0.25.0", features = ["extension-module", "multiple-pymethods"] } numpy = { path = "../.." } ndarray = { version = "0.16", features = ["rayon", "blas"] } blas-src = { version = "0.8", features = ["openblas"] } diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml index 65cf170b6..9920d1792 100644 --- a/examples/simple/Cargo.toml +++ b/examples/simple/Cargo.toml @@ -9,7 +9,7 @@ name = "rust_ext" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.24.0", features = ["extension-module", "abi3-py37"] } +pyo3 = { version = "0.25.0", features = ["extension-module", "abi3-py37"] } numpy = { path = "../.." } [workspace] diff --git a/src/array.rs b/src/array.rs index 4d69aba80..6d5ad222f 100644 --- a/src/array.rs +++ b/src/array.rs @@ -216,23 +216,6 @@ impl PyArray { Self::new_uninit(py, dims, ptr::null_mut(), flags) } - /// Deprecated name for [`PyArray::new`]. - /// - /// # Safety - /// See [`PyArray::new`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::new`")] - #[inline] - pub unsafe fn new_bound<'py, ID>( - py: Python<'py>, - dims: ID, - is_fortran: bool, - ) -> Bound<'py, Self> - where - ID: IntoDimension, - { - Self::new(py, dims, is_fortran) - } - pub(crate) unsafe fn new_uninit<'py, ID>( py: Python<'py>, dims: ID, @@ -358,22 +341,6 @@ impl PyArray { ) } - /// Deprecated name for [`PyArray::borrow_from_array`]. - /// - /// # Safety - /// See [`PyArray::borrow_from_array`] - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::borrow_from_array`")] - #[inline] - pub unsafe fn borrow_from_array_bound<'py, S>( - array: &ArrayBase, - container: Bound<'py, PyAny>, - ) -> Bound<'py, Self> - where - S: Data, - { - Self::borrow_from_array(array, container) - } - /// Construct a new NumPy array filled with zeros. /// /// If `is_fortran` is true, then it has Fortran/column-major order, @@ -416,16 +383,6 @@ impl PyArray { } } - /// Deprecated name for [`PyArray::zeros`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::zeros`")] - #[inline] - pub fn zeros_bound(py: Python<'_>, dims: ID, is_fortran: bool) -> Bound<'_, Self> - where - ID: IntoDimension, - { - Self::zeros(py, dims, is_fortran) - } - /// Constructs a NumPy from an [`ndarray::Array`] /// /// This method uses the internal [`Vec`] of the [`ndarray::Array`] as the base object of the NumPy array. @@ -456,12 +413,6 @@ impl PyArray { ) } } - /// Deprecated name for [`PyArray::from_owned_array`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_owned_array`")] - #[inline] - pub fn from_owned_array_bound(py: Python<'_>, arr: Array) -> Bound<'_, Self> { - Self::from_owned_array(py, arr) - } /// Construct a NumPy array from a [`ndarray::ArrayBase`]. /// @@ -487,16 +438,6 @@ impl PyArray { { ToPyArray::to_pyarray(arr, py) } - - /// Deprecated name for [`PyArray::from_array`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_array`")] - #[inline] - pub fn from_array_bound<'py, S>(py: Python<'py>, arr: &ArrayBase) -> Bound<'py, Self> - where - S: Data, - { - Self::from_array(py, arr) - } } impl PyArray { @@ -548,19 +489,6 @@ impl PyArray { ) } } - - /// Deprecated name for [`PyArray::from_owned_object_array`]. - #[deprecated( - since = "0.23.0", - note = "renamed to `PyArray::from_owned_object_array`" - )] - #[inline] - pub fn from_owned_object_array_bound( - py: Python<'_>, - arr: Array, D>, - ) -> Bound<'_, Self> { - Self::from_owned_object_array(py, arr) - } } impl PyArray { @@ -587,13 +515,6 @@ impl PyArray { } } - /// Deprecated name for [`PyArray::from_slice`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_slice`")] - #[inline] - pub fn from_slice_bound<'py>(py: Python<'py>, slice: &[T]) -> Bound<'py, Self> { - Self::from_slice(py, slice) - } - /// Construct a one-dimensional array from a [`Vec`][Vec]. /// /// # Example @@ -613,13 +534,6 @@ impl PyArray { vec.into_pyarray(py) } - /// Deprecated name for [`PyArray::from_vec`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec`")] - #[inline] - pub fn from_vec_bound<'py>(py: Python<'py>, vec: Vec) -> Bound<'py, Self> { - Self::from_vec(py, vec) - } - /// Construct a one-dimensional array from an [`Iterator`]. /// /// If no reliable [`size_hint`][Iterator::size_hint] is available, @@ -643,16 +557,6 @@ impl PyArray { let data = iter.into_iter().collect::>(); data.into_pyarray(py) } - - /// Deprecated name for [`PyArray::from_iter`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_iter`")] - #[inline] - pub fn from_iter_bound(py: Python<'_>, iter: I) -> Bound<'_, Self> - where - I: IntoIterator, - { - Self::from_iter(py, iter) - } } impl PyArray { @@ -694,16 +598,6 @@ impl PyArray { Ok(array) } } - - /// Deprecated name for [`PyArray::from_vec2`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec2`")] - #[inline] - pub fn from_vec2_bound<'py>( - py: Python<'py>, - v: &[Vec], - ) -> Result, FromVecError> { - Self::from_vec2(py, v) - } } impl PyArray { @@ -764,16 +658,6 @@ impl PyArray { Ok(array) } } - - /// Deprecated name for [`PyArray::from_vec3`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec3`")] - #[inline] - pub fn from_vec3_bound<'py>( - py: Python<'py>, - v: &[Vec>], - ) -> Result, FromVecError> { - Self::from_vec3(py, v) - } } impl> PyArray { @@ -810,13 +694,6 @@ impl> PyArray { Bound::from_owned_ptr(py, ptr).downcast_into_unchecked() } } - - /// Deprecated name for [`PyArray::arange`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArray::arange`")] - #[inline] - pub fn arange_bound<'py>(py: Python<'py>, start: T, stop: T, step: T) -> Bound<'py, Self> { - Self::arange(py, start, stop, step) - } } unsafe fn clone_elements(py: Python<'_>, elems: &[T], data_ptr: &mut *mut T) { diff --git a/src/convert.rs b/src/convert.rs index 66c557b1b..b4c71ec2d 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -42,16 +42,6 @@ pub trait IntoPyArray: Sized { /// Consumes `self` and moves its data into a NumPy array. fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray>; - - /// Deprecated name for [`IntoPyArray::into_pyarray`]. - #[deprecated(since = "0.23.0", note = "renamed to `IntoPyArray::into_pyarray`")] - #[inline] - fn into_pyarray_bound<'py>( - self, - py: Python<'py>, - ) -> Bound<'py, PyArray> { - self.into_pyarray(py) - } } impl IntoPyArray for Box<[T]> { @@ -144,13 +134,6 @@ pub trait ToPyArray { /// Copies the content pointed to by `&self` into a newly allocated NumPy array. fn to_pyarray<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray>; - - /// Deprecated name for [ToPyArray::to_pyarray`]. - #[deprecated(since = "0.23.0", note = "renamed to ToPyArray::to_pyarray`")] - #[inline] - fn to_pyarray_bound<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray> { - self.to_pyarray(py) - } } impl ToPyArray for [T] { diff --git a/src/dtype.rs b/src/dtype.rs index fd45bb5ec..ee497f672 100644 --- a/src/dtype.rs +++ b/src/dtype.rs @@ -68,13 +68,6 @@ pub fn dtype<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr> { T::get_dtype(py) } -/// Deprecated name for [`dtype`]. -#[deprecated(since = "0.23.0", note = "renamed to `dtype`")] -#[inline] -pub fn dtype_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr> { - dtype::(py) -} - impl PyArrayDescr { /// Creates a new type descriptor ("dtype") object from an arbitrary object. /// @@ -108,43 +101,18 @@ impl PyArrayDescr { ) } - /// Deprecated name for [`PyArrayDescr::new`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::new`")] - #[allow(deprecated)] - #[inline] - pub fn new_bound<'py, T: pyo3::ToPyObject + ?Sized>( - py: Python<'py>, - ob: &T, - ) -> PyResult> { - Self::new(py, ob.to_object(py)) - } - /// Shortcut for creating a type descriptor of `object` type. #[inline] pub fn object(py: Python<'_>) -> Bound<'_, Self> { Self::from_npy_type(py, NPY_TYPES::NPY_OBJECT) } - /// Deprecated name for [`PyArrayDescr::object`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::object`")] - #[inline] - pub fn object_bound(py: Python<'_>) -> Bound<'_, Self> { - Self::object(py) - } - /// Returns the type descriptor for a registered type. #[inline] pub fn of<'py, T: Element>(py: Python<'py>) -> Bound<'py, Self> { T::get_dtype(py) } - /// Deprecated name for [`PyArrayDescr::of`]. - #[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::of`")] - #[inline] - pub fn of_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, Self> { - Self::of::(py) - } - fn from_npy_type<'py>(py: Python<'py>, npy_type: NPY_TYPES) -> Bound<'py, Self> { unsafe { let descr = PY_ARRAY_API.PyArray_DescrFromType(py, npy_type as _); @@ -506,13 +474,6 @@ pub unsafe trait Element: Sized + Send + Sync { /// Returns the associated type descriptor ("dtype") for the given element type. fn get_dtype(py: Python<'_>) -> Bound<'_, PyArrayDescr>; - /// Deprecated name for [`Element::get_dtype`]. - #[deprecated(since = "0.23.0", note = "renamed to `Element::get_dtype`")] - #[inline] - fn get_dtype_bound(py: Python<'_>) -> Bound<'_, PyArrayDescr> { - Self::get_dtype(py) - } - /// Create a clone of the value while the GIL is guaranteed to be held. fn clone_ref(&self, py: Python<'_>) -> Self; @@ -700,13 +661,13 @@ mod tests { Python::with_gil(|py| { assert!(PyArrayDescr::new(py, "float64") .unwrap() - .is(&dtype::(py))); + .is(dtype::(py))); let dt = PyArrayDescr::new(py, [("a", "O"), ("b", "?")].as_ref()).unwrap(); assert_eq!(dt.names(), Some(vec!["a".to_owned(), "b".to_owned()])); assert!(dt.has_object()); - assert!(dt.get_field("a").unwrap().0.is(&dtype::(py))); - assert!(dt.get_field("b").unwrap().0.is(&dtype::(py))); + assert!(dt.get_field("a").unwrap().0.is(dtype::(py))); + assert!(dt.get_field("b").unwrap().0.is(dtype::(py))); assert!(PyArrayDescr::new(py, 123_usize).is_err()); }); diff --git a/src/lib.rs b/src/lib.rs index e147a9c18..195465022 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,15 +105,11 @@ pub use crate::borrow::{ PyReadwriteArray5, PyReadwriteArray6, PyReadwriteArrayDyn, }; pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray}; -#[allow(deprecated)] -pub use crate::dtype::dtype_bound; pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr, PyArrayDescrMethods}; pub use crate::error::{BorrowError, FromVecError, NotContiguousError}; pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API}; pub use crate::strings::{PyFixedString, PyFixedUnicode}; pub use crate::sum_products::{dot, einsum, inner}; -#[allow(deprecated)] -pub use crate::sum_products::{dot_bound, einsum_bound, inner_bound}; pub use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods}; pub use ndarray::{array, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn}; @@ -180,18 +176,3 @@ macro_rules! pyarray { $crate::IntoPyArray::into_pyarray($crate::array![$($x,)*], $py) }}; } - -/// Deprecated name for [`pyarray`]. -#[deprecated(since = "0.23.0", note = "renamed to `pyarray`")] -#[macro_export] -macro_rules! pyarray_bound { - ($py: ident, $([$([$($x:expr),* $(,)*]),+ $(,)*]),+ $(,)*) => {{ - $crate::IntoPyArray::into_pyarray($crate::array![$([$([$($x,)*],)*],)*], $py) - }}; - ($py: ident, $([$($x:expr),* $(,)*]),+ $(,)*) => {{ - $crate::IntoPyArray::into_pyarray($crate::array![$([$($x,)*],)*], $py) - }}; - ($py: ident, $($x:expr),* $(,)*) => {{ - $crate::IntoPyArray::into_pyarray($crate::array![$($x,)*], $py) - }}; -} diff --git a/src/sum_products.rs b/src/sum_products.rs index 8aadbdc66..95b6bd8e9 100644 --- a/src/sum_products.rs +++ b/src/sum_products.rs @@ -74,22 +74,6 @@ where obj.extract() } -/// Deprecated name for [`inner`]. -#[deprecated(since = "0.23.0", note = "renamed to `inner`")] -#[inline] -pub fn inner_bound<'py, T, DIN1, DIN2, OUT>( - array1: &Bound<'py, PyArray>, - array2: &Bound<'py, PyArray>, -) -> PyResult -where - T: Element, - DIN1: Dimension, - DIN2: Dimension, - OUT: ArrayOrScalar<'py, T>, -{ - inner(array1, array2) -} - /// Return the dot product of two arrays. /// /// [NumPy's documentation][dot] has the details. @@ -148,22 +132,6 @@ where obj.extract() } -/// Deprecated name for [`dot`]. -#[deprecated(since = "0.23.0", note = "renamed to `dot`")] -#[inline] -pub fn dot_bound<'py, T, DIN1, DIN2, OUT>( - array1: &Bound<'py, PyArray>, - array2: &Bound<'py, PyArray>, -) -> PyResult -where - T: Element, - DIN1: Dimension, - DIN2: Dimension, - OUT: ArrayOrScalar<'py, T>, -{ - dot(array1, array2) -} - /// Return the Einstein summation convention of given tensors. /// /// This is usually invoked via the the [`einsum!`][crate::einsum!] macro. @@ -197,20 +165,6 @@ where obj.extract() } -/// Deprecated name for [`einsum`]. -#[deprecated(since = "0.23.0", note = "renamed to `einsum`")] -#[inline] -pub fn einsum_bound<'py, T, OUT>( - subscripts: &str, - arrays: &[Borrowed<'_, 'py, PyArray>], -) -> PyResult -where - T: Element, - OUT: ArrayOrScalar<'py, T>, -{ - einsum(subscripts, arrays) -} - /// Return the Einstein summation convention of given tensors. /// /// For more about the Einstein summation convention, please refer to @@ -244,13 +198,3 @@ macro_rules! einsum { $crate::einsum(concat!($subscripts, "\0"), &arrays) }}; } - -/// Deprecated name for [`einsum!`]. -#[deprecated(since = "0.23.0", note = "renamed to `einsum!`")] -#[macro_export] -macro_rules! einsum_bound { - ($subscripts:literal $(,$array:ident)+ $(,)*) => {{ - let arrays = [$($array.to_dyn().as_borrowed(),)+]; - $crate::einsum(concat!($subscripts, "\0"), &arrays) - }}; -}