Skip to content

Commit 3d1116a

Browse files
update pyo3 to 0.25 (#492)
1 parent 52acfd7 commit 3d1116a

File tree

9 files changed

+10
-264
lines changed

9 files changed

+10
-264
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numpy"
3-
version = "0.24.0"
3+
version = "0.25.0"
44
authors = [
55
"The rust-numpy Project Developers",
66
"PyO3 Project and Contributors <https://github.com/PyO3>"
@@ -22,15 +22,15 @@ num-complex = ">= 0.2, < 0.5"
2222
num-integer = "0.1"
2323
num-traits = "0.2"
2424
ndarray = ">= 0.15, < 0.17"
25-
pyo3 = { version = "0.24.1", default-features = false, features = ["macros"] }
25+
pyo3 = { version = "0.25.0", default-features = false, features = ["macros"] }
2626
rustc-hash = "2.0"
2727

2828
[dev-dependencies]
29-
pyo3 = { version = "0.24", default-features = false, features = ["auto-initialize"] }
29+
pyo3 = { version = "0.25", default-features = false, features = ["auto-initialize"] }
3030
nalgebra = { version = ">=0.30, <0.34", default-features = false, features = ["std"] }
3131

3232
[build-dependencies]
33-
pyo3-build-config = { version = "0.24", features = ["resolve-config"] }
33+
pyo3-build-config = { version = "0.25", features = ["resolve-config"] }
3434

3535
[package.metadata.docs.rs]
3636
all-features = true

examples/linalg/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_linalg"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.24.1", features = ["extension-module"] }
12+
pyo3 = { version = "0.25.0", features = ["extension-module"] }
1313
numpy = { path = "../.." }
1414
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }
1515

examples/parallel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_parallel"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.24.0", features = ["extension-module", "multiple-pymethods"] }
12+
pyo3 = { version = "0.25.0", features = ["extension-module", "multiple-pymethods"] }
1313
numpy = { path = "../.." }
1414
ndarray = { version = "0.16", features = ["rayon", "blas"] }
1515
blas-src = { version = "0.8", features = ["openblas"] }

examples/simple/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_ext"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.24.0", features = ["extension-module", "abi3-py37"] }
12+
pyo3 = { version = "0.25.0", features = ["extension-module", "abi3-py37"] }
1313
numpy = { path = "../.." }
1414

1515
[workspace]

src/array.rs

-123
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,6 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
216216
Self::new_uninit(py, dims, ptr::null_mut(), flags)
217217
}
218218

219-
/// Deprecated name for [`PyArray::new`].
220-
///
221-
/// # Safety
222-
/// See [`PyArray::new`].
223-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::new`")]
224-
#[inline]
225-
pub unsafe fn new_bound<'py, ID>(
226-
py: Python<'py>,
227-
dims: ID,
228-
is_fortran: bool,
229-
) -> Bound<'py, Self>
230-
where
231-
ID: IntoDimension<Dim = D>,
232-
{
233-
Self::new(py, dims, is_fortran)
234-
}
235-
236219
pub(crate) unsafe fn new_uninit<'py, ID>(
237220
py: Python<'py>,
238221
dims: ID,
@@ -358,22 +341,6 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
358341
)
359342
}
360343

361-
/// Deprecated name for [`PyArray::borrow_from_array`].
362-
///
363-
/// # Safety
364-
/// See [`PyArray::borrow_from_array`]
365-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::borrow_from_array`")]
366-
#[inline]
367-
pub unsafe fn borrow_from_array_bound<'py, S>(
368-
array: &ArrayBase<S, D>,
369-
container: Bound<'py, PyAny>,
370-
) -> Bound<'py, Self>
371-
where
372-
S: Data<Elem = T>,
373-
{
374-
Self::borrow_from_array(array, container)
375-
}
376-
377344
/// Construct a new NumPy array filled with zeros.
378345
///
379346
/// If `is_fortran` is true, then it has Fortran/column-major order,
@@ -416,16 +383,6 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
416383
}
417384
}
418385

419-
/// Deprecated name for [`PyArray::zeros`].
420-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::zeros`")]
421-
#[inline]
422-
pub fn zeros_bound<ID>(py: Python<'_>, dims: ID, is_fortran: bool) -> Bound<'_, Self>
423-
where
424-
ID: IntoDimension<Dim = D>,
425-
{
426-
Self::zeros(py, dims, is_fortran)
427-
}
428-
429386
/// Constructs a NumPy from an [`ndarray::Array`]
430387
///
431388
/// This method uses the internal [`Vec`] of the [`ndarray::Array`] as the base object of the NumPy array.
@@ -456,12 +413,6 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
456413
)
457414
}
458415
}
459-
/// Deprecated name for [`PyArray::from_owned_array`].
460-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_owned_array`")]
461-
#[inline]
462-
pub fn from_owned_array_bound(py: Python<'_>, arr: Array<T, D>) -> Bound<'_, Self> {
463-
Self::from_owned_array(py, arr)
464-
}
465416

466417
/// Construct a NumPy array from a [`ndarray::ArrayBase`].
467418
///
@@ -487,16 +438,6 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
487438
{
488439
ToPyArray::to_pyarray(arr, py)
489440
}
490-
491-
/// Deprecated name for [`PyArray::from_array`].
492-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_array`")]
493-
#[inline]
494-
pub fn from_array_bound<'py, S>(py: Python<'py>, arr: &ArrayBase<S, D>) -> Bound<'py, Self>
495-
where
496-
S: Data<Elem = T>,
497-
{
498-
Self::from_array(py, arr)
499-
}
500441
}
501442

502443
impl<D: Dimension> PyArray<PyObject, D> {
@@ -548,19 +489,6 @@ impl<D: Dimension> PyArray<PyObject, D> {
548489
)
549490
}
550491
}
551-
552-
/// Deprecated name for [`PyArray::from_owned_object_array`].
553-
#[deprecated(
554-
since = "0.23.0",
555-
note = "renamed to `PyArray::from_owned_object_array`"
556-
)]
557-
#[inline]
558-
pub fn from_owned_object_array_bound<T>(
559-
py: Python<'_>,
560-
arr: Array<Py<T>, D>,
561-
) -> Bound<'_, Self> {
562-
Self::from_owned_object_array(py, arr)
563-
}
564492
}
565493

566494
impl<T: Element> PyArray<T, Ix1> {
@@ -587,13 +515,6 @@ impl<T: Element> PyArray<T, Ix1> {
587515
}
588516
}
589517

590-
/// Deprecated name for [`PyArray::from_slice`].
591-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_slice`")]
592-
#[inline]
593-
pub fn from_slice_bound<'py>(py: Python<'py>, slice: &[T]) -> Bound<'py, Self> {
594-
Self::from_slice(py, slice)
595-
}
596-
597518
/// Construct a one-dimensional array from a [`Vec<T>`][Vec].
598519
///
599520
/// # Example
@@ -613,13 +534,6 @@ impl<T: Element> PyArray<T, Ix1> {
613534
vec.into_pyarray(py)
614535
}
615536

616-
/// Deprecated name for [`PyArray::from_vec`].
617-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec`")]
618-
#[inline]
619-
pub fn from_vec_bound<'py>(py: Python<'py>, vec: Vec<T>) -> Bound<'py, Self> {
620-
Self::from_vec(py, vec)
621-
}
622-
623537
/// Construct a one-dimensional array from an [`Iterator`].
624538
///
625539
/// If no reliable [`size_hint`][Iterator::size_hint] is available,
@@ -643,16 +557,6 @@ impl<T: Element> PyArray<T, Ix1> {
643557
let data = iter.into_iter().collect::<Vec<_>>();
644558
data.into_pyarray(py)
645559
}
646-
647-
/// Deprecated name for [`PyArray::from_iter`].
648-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_iter`")]
649-
#[inline]
650-
pub fn from_iter_bound<I>(py: Python<'_>, iter: I) -> Bound<'_, Self>
651-
where
652-
I: IntoIterator<Item = T>,
653-
{
654-
Self::from_iter(py, iter)
655-
}
656560
}
657561

658562
impl<T: Element> PyArray<T, Ix2> {
@@ -694,16 +598,6 @@ impl<T: Element> PyArray<T, Ix2> {
694598
Ok(array)
695599
}
696600
}
697-
698-
/// Deprecated name for [`PyArray::from_vec2`].
699-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec2`")]
700-
#[inline]
701-
pub fn from_vec2_bound<'py>(
702-
py: Python<'py>,
703-
v: &[Vec<T>],
704-
) -> Result<Bound<'py, Self>, FromVecError> {
705-
Self::from_vec2(py, v)
706-
}
707601
}
708602

709603
impl<T: Element> PyArray<T, Ix3> {
@@ -764,16 +658,6 @@ impl<T: Element> PyArray<T, Ix3> {
764658
Ok(array)
765659
}
766660
}
767-
768-
/// Deprecated name for [`PyArray::from_vec3`].
769-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::from_vec3`")]
770-
#[inline]
771-
pub fn from_vec3_bound<'py>(
772-
py: Python<'py>,
773-
v: &[Vec<Vec<T>>],
774-
) -> Result<Bound<'py, Self>, FromVecError> {
775-
Self::from_vec3(py, v)
776-
}
777661
}
778662

779663
impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
@@ -810,13 +694,6 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
810694
Bound::from_owned_ptr(py, ptr).downcast_into_unchecked()
811695
}
812696
}
813-
814-
/// Deprecated name for [`PyArray::arange`].
815-
#[deprecated(since = "0.23.0", note = "renamed to `PyArray::arange`")]
816-
#[inline]
817-
pub fn arange_bound<'py>(py: Python<'py>, start: T, stop: T, step: T) -> Bound<'py, Self> {
818-
Self::arange(py, start, stop, step)
819-
}
820697
}
821698

822699
unsafe fn clone_elements<T: Element>(py: Python<'_>, elems: &[T], data_ptr: &mut *mut T) {

src/convert.rs

-17
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ pub trait IntoPyArray: Sized {
4242

4343
/// Consumes `self` and moves its data into a NumPy array.
4444
fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>>;
45-
46-
/// Deprecated name for [`IntoPyArray::into_pyarray`].
47-
#[deprecated(since = "0.23.0", note = "renamed to `IntoPyArray::into_pyarray`")]
48-
#[inline]
49-
fn into_pyarray_bound<'py>(
50-
self,
51-
py: Python<'py>,
52-
) -> Bound<'py, PyArray<Self::Item, Self::Dim>> {
53-
self.into_pyarray(py)
54-
}
5545
}
5646

5747
impl<T: Element> IntoPyArray for Box<[T]> {
@@ -144,13 +134,6 @@ pub trait ToPyArray {
144134

145135
/// Copies the content pointed to by `&self` into a newly allocated NumPy array.
146136
fn to_pyarray<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>>;
147-
148-
/// Deprecated name for [ToPyArray::to_pyarray`].
149-
#[deprecated(since = "0.23.0", note = "renamed to ToPyArray::to_pyarray`")]
150-
#[inline]
151-
fn to_pyarray_bound<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>> {
152-
self.to_pyarray(py)
153-
}
154137
}
155138

156139
impl<T: Element> ToPyArray for [T] {

src/dtype.rs

+3-42
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ pub fn dtype<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr> {
6868
T::get_dtype(py)
6969
}
7070

71-
/// Deprecated name for [`dtype`].
72-
#[deprecated(since = "0.23.0", note = "renamed to `dtype`")]
73-
#[inline]
74-
pub fn dtype_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr> {
75-
dtype::<T>(py)
76-
}
77-
7871
impl PyArrayDescr {
7972
/// Creates a new type descriptor ("dtype") object from an arbitrary object.
8073
///
@@ -108,43 +101,18 @@ impl PyArrayDescr {
108101
)
109102
}
110103

111-
/// Deprecated name for [`PyArrayDescr::new`].
112-
#[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::new`")]
113-
#[allow(deprecated)]
114-
#[inline]
115-
pub fn new_bound<'py, T: pyo3::ToPyObject + ?Sized>(
116-
py: Python<'py>,
117-
ob: &T,
118-
) -> PyResult<Bound<'py, Self>> {
119-
Self::new(py, ob.to_object(py))
120-
}
121-
122104
/// Shortcut for creating a type descriptor of `object` type.
123105
#[inline]
124106
pub fn object(py: Python<'_>) -> Bound<'_, Self> {
125107
Self::from_npy_type(py, NPY_TYPES::NPY_OBJECT)
126108
}
127109

128-
/// Deprecated name for [`PyArrayDescr::object`].
129-
#[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::object`")]
130-
#[inline]
131-
pub fn object_bound(py: Python<'_>) -> Bound<'_, Self> {
132-
Self::object(py)
133-
}
134-
135110
/// Returns the type descriptor for a registered type.
136111
#[inline]
137112
pub fn of<'py, T: Element>(py: Python<'py>) -> Bound<'py, Self> {
138113
T::get_dtype(py)
139114
}
140115

141-
/// Deprecated name for [`PyArrayDescr::of`].
142-
#[deprecated(since = "0.23.0", note = "renamed to `PyArrayDescr::of`")]
143-
#[inline]
144-
pub fn of_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, Self> {
145-
Self::of::<T>(py)
146-
}
147-
148116
fn from_npy_type<'py>(py: Python<'py>, npy_type: NPY_TYPES) -> Bound<'py, Self> {
149117
unsafe {
150118
let descr = PY_ARRAY_API.PyArray_DescrFromType(py, npy_type as _);
@@ -506,13 +474,6 @@ pub unsafe trait Element: Sized + Send + Sync {
506474
/// Returns the associated type descriptor ("dtype") for the given element type.
507475
fn get_dtype(py: Python<'_>) -> Bound<'_, PyArrayDescr>;
508476

509-
/// Deprecated name for [`Element::get_dtype`].
510-
#[deprecated(since = "0.23.0", note = "renamed to `Element::get_dtype`")]
511-
#[inline]
512-
fn get_dtype_bound(py: Python<'_>) -> Bound<'_, PyArrayDescr> {
513-
Self::get_dtype(py)
514-
}
515-
516477
/// Create a clone of the value while the GIL is guaranteed to be held.
517478
fn clone_ref(&self, py: Python<'_>) -> Self;
518479

@@ -700,13 +661,13 @@ mod tests {
700661
Python::with_gil(|py| {
701662
assert!(PyArrayDescr::new(py, "float64")
702663
.unwrap()
703-
.is(&dtype::<f64>(py)));
664+
.is(dtype::<f64>(py)));
704665

705666
let dt = PyArrayDescr::new(py, [("a", "O"), ("b", "?")].as_ref()).unwrap();
706667
assert_eq!(dt.names(), Some(vec!["a".to_owned(), "b".to_owned()]));
707668
assert!(dt.has_object());
708-
assert!(dt.get_field("a").unwrap().0.is(&dtype::<PyObject>(py)));
709-
assert!(dt.get_field("b").unwrap().0.is(&dtype::<bool>(py)));
669+
assert!(dt.get_field("a").unwrap().0.is(dtype::<PyObject>(py)));
670+
assert!(dt.get_field("b").unwrap().0.is(dtype::<bool>(py)));
710671

711672
assert!(PyArrayDescr::new(py, 123_usize).is_err());
712673
});

0 commit comments

Comments
 (0)