Skip to content

Commit f46bd07

Browse files
committed
restore deprecation messages
1 parent 5847743 commit f46bd07

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

src/array.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ impl<T, D> PyArray<T, D> {
229229
/// assert_eq!(array.bind(py).readonly().as_slice().unwrap(), [0.0; 5]);
230230
/// });
231231
/// ```
232+
#[deprecated(since = "0.21.0", note = "use Bound::unbind() instead")]
232233
pub fn to_owned(&self) -> Py<Self> {
233234
unsafe { Py::from_borrowed_ptr(self.py(), self.as_ptr()) }
234235
}
@@ -238,6 +239,7 @@ impl<T, D> PyArray<T, D> {
238239
/// # Safety
239240
///
240241
/// This is a wrapper around [`pyo3::FromPyPointer::from_owned_ptr_or_opt`] and inherits its safety contract.
242+
#[deprecated(since = "0.21.0", note = "use Bound::from_owned_ptr() instead")]
241243
pub unsafe fn from_owned_ptr<'py>(py: Python<'py>, ptr: *mut ffi::PyObject) -> &'py Self {
242244
#![allow(deprecated)]
243245
py.from_owned_ptr(ptr)
@@ -248,6 +250,7 @@ impl<T, D> PyArray<T, D> {
248250
/// # Safety
249251
///
250252
/// This is a wrapper around [`pyo3::FromPyPointer::from_borrowed_ptr_or_opt`] and inherits its safety contract.
253+
#[deprecated(since = "0.21.0", note = "use Bound::from_borrowed_ptr() instead")]
251254
pub unsafe fn from_borrowed_ptr<'py>(py: Python<'py>, ptr: *mut ffi::PyObject) -> &'py Self {
252255
#![allow(deprecated)]
253256
py.from_borrowed_ptr(ptr)
@@ -577,6 +580,10 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
577580
///
578581
/// # Safety
579582
/// Same as [`PyArray<T, D>::new_bound`]
583+
#[deprecated(
584+
since = "0.21.0",
585+
note = "will be replaced by `PyArray::new_bound` in the future"
586+
)]
580587
pub unsafe fn new<'py, ID>(py: Python<'py>, dims: ID, is_fortran: bool) -> &Self
581588
where
582589
ID: IntoDimension<Dim = D>,
@@ -588,6 +595,10 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
588595
///
589596
/// # Safety
590597
/// Same as [`PyArray<T, D>::borrow_from_array_bound`]
598+
#[deprecated(
599+
since = "0.21.0",
600+
note = "will be replaced by `PyArray::borrow_from_array_bound` in the future"
601+
)]
591602
pub unsafe fn borrow_from_array<'py, S>(
592603
array: &ArrayBase<S, D>,
593604
container: &'py PyAny,
@@ -599,6 +610,10 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
599610
}
600611

601612
/// Deprecated form of [`PyArray<T, D>::zeros_bound`]
613+
#[deprecated(
614+
since = "0.21.0",
615+
note = "will be replaced by `PyArray::zeros_bound` in the future"
616+
)]
602617
pub fn zeros<'py, ID>(py: Python<'py>, dims: ID, is_fortran: bool) -> &Self
603618
where
604619
ID: IntoDimension<Dim = D>,
@@ -641,6 +656,10 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
641656
}
642657

643658
/// Deprecated form of [`PyArray<T, D>::from_owned_array_bound`]
659+
#[deprecated(
660+
since = "0.21.0",
661+
note = "will be replaced by PyArray::from_owned_array_bound in the future"
662+
)]
644663
pub fn from_owned_array<'py>(py: Python<'py>, arr: Array<T, D>) -> &'py Self {
645664
Self::from_owned_array_bound(py, arr).into_gil_ref()
646665
}
@@ -821,6 +840,10 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
821840
}
822841

823842
/// Deprecated form of [`PyArray<T, D>::from_array_bound`]
843+
#[deprecated(
844+
since = "0.21.0",
845+
note = "will be replaced by PyArray::from_array_bound in the future"
846+
)]
824847
pub fn from_array<'py, S>(py: Python<'py>, arr: &ArrayBase<S, D>) -> &'py Self
825848
where
826849
S: Data<Elem = T>,
@@ -981,6 +1004,10 @@ where
9811004
impl<D: Dimension> PyArray<PyObject, D> {
9821005
/// Deprecated form of [`PyArray<T, D>::from_owned_object_array_bound`]
9831006
#[cfg(feature = "gil-refs")]
1007+
#[deprecated(
1008+
since = "0.21.0",
1009+
note = "will be replaced by PyArray::from_owned_object_array_bound in the future"
1010+
)]
9841011
pub fn from_owned_object_array<'py, T>(py: Python<'py>, arr: Array<Py<T>, D>) -> &'py Self {
9851012
Self::from_owned_object_array_bound(py, arr).into_gil_ref()
9861013
}
@@ -1119,17 +1146,29 @@ impl<T: Element> PyArray<T, Ix1> {
11191146
#[cfg(feature = "gil-refs")]
11201147
impl<T: Element> PyArray<T, Ix1> {
11211148
/// Deprecated form of [`PyArray<T, Ix1>::from_slice_bound`]
1149+
#[deprecated(
1150+
since = "0.21.0",
1151+
note = "will be replaced by `PyArray::from_slice_bound` in the future"
1152+
)]
11221153
pub fn from_slice<'py>(py: Python<'py>, slice: &[T]) -> &'py Self {
11231154
Self::from_slice_bound(py, slice).into_gil_ref()
11241155
}
11251156

11261157
/// Deprecated form of [`PyArray<T, Ix1>::from_vec_bound`]
11271158
#[inline(always)]
1159+
#[deprecated(
1160+
since = "0.21.0",
1161+
note = "will be replaced by `PyArray::from_vec_bound` in the future"
1162+
)]
11281163
pub fn from_vec<'py>(py: Python<'py>, vec: Vec<T>) -> &'py Self {
11291164
Self::from_vec_bound(py, vec).into_gil_ref()
11301165
}
11311166

11321167
/// Deprecated form of [`PyArray<T, Ix1>::from_iter_bound`]
1168+
#[deprecated(
1169+
since = "0.21.0",
1170+
note = "will be replaced by PyArray::from_iter_bound in the future"
1171+
)]
11331172
pub fn from_iter<'py, I>(py: Python<'py>, iter: I) -> &'py Self
11341173
where
11351174
I: IntoIterator<Item = T>,
@@ -1141,6 +1180,10 @@ impl<T: Element> PyArray<T, Ix1> {
11411180
impl<T: Element> PyArray<T, Ix2> {
11421181
/// Deprecated form of [`PyArray<T, Ix2>::from_vec2_bound`]
11431182
#[cfg(feature = "gil-refs")]
1183+
#[deprecated(
1184+
since = "0.21.0",
1185+
note = "will be replaced by `PyArray::from_vec2_bound` in the future"
1186+
)]
11441187
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
11451188
Self::from_vec2_bound(py, v).map(Bound::into_gil_ref)
11461189
}
@@ -1191,6 +1234,10 @@ impl<T: Element> PyArray<T, Ix2> {
11911234
impl<T: Element> PyArray<T, Ix3> {
11921235
/// Deprecated form of [`PyArray<T, Ix3>::from_vec3_bound`]
11931236
#[cfg(feature = "gil-refs")]
1237+
#[deprecated(
1238+
since = "0.21.0",
1239+
note = "will be replaced by `PyArray::from_vec3_bound` in the future"
1240+
)]
11941241
pub fn from_vec3<'py>(py: Python<'py>, v: &[Vec<Vec<T>>]) -> Result<&'py Self, FromVecError> {
11951242
Self::from_vec3_bound(py, v).map(Bound::into_gil_ref)
11961243
}
@@ -1428,6 +1475,10 @@ impl<T: Element, D> PyArray<T, D> {
14281475
impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
14291476
/// Deprecated form of [`PyArray<T, Ix1>::arange_bound`]
14301477
#[cfg(feature = "gil-refs")]
1478+
#[deprecated(
1479+
since = "0.21.0",
1480+
note = "will be replaced by PyArray::arange_bound in the future"
1481+
)]
14311482
pub fn arange<'py>(py: Python<'py>, start: T, stop: T, step: T) -> &Self {
14321483
Self::arange_bound(py, start, stop, step).into_gil_ref()
14331484
}

src/dtype.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ pyobject_native_type_extract!(PyArrayDescr);
7171

7272
/// Returns the type descriptor ("dtype") for a registered type.
7373
#[cfg(feature = "gil-refs")]
74+
#[deprecated(
75+
since = "0.21.0",
76+
note = "This will be replaced by `dtype_bound` in the future."
77+
)]
7478
pub fn dtype<'py, T: Element>(py: Python<'py>) -> &'py PyArrayDescr {
7579
T::get_dtype_bound(py).into_gil_ref()
7680
}
@@ -136,6 +140,10 @@ impl PyArrayDescr {
136140
/// Equivalent to invoking the constructor of [`numpy.dtype`][dtype].
137141
///
138142
/// [dtype]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.html
143+
#[deprecated(
144+
since = "0.21.0",
145+
note = "This will be replace by `new_bound` in the future."
146+
)]
139147
pub fn new<'py, T: ToPyObject + ?Sized>(py: Python<'py>, ob: &T) -> PyResult<&'py Self> {
140148
Self::new_bound(py, ob).map(Bound::into_gil_ref)
141149
}
@@ -153,11 +161,19 @@ impl PyArrayDescr {
153161
}
154162

155163
/// Shortcut for creating a type descriptor of `object` type.
164+
#[deprecated(
165+
since = "0.21.0",
166+
note = "This will be replaced by `object_bound` in the future."
167+
)]
156168
pub fn object<'py>(py: Python<'py>) -> &'py Self {
157169
Self::object_bound(py).into_gil_ref()
158170
}
159171

160172
/// Returns the type descriptor for a registered type.
173+
#[deprecated(
174+
since = "0.21.0",
175+
note = "This will be replaced by `of_bound` in the future."
176+
)]
161177
pub fn of<'py, T: Element>(py: Python<'py>) -> &'py Self {
162178
Self::of_bound::<T>(py).into_gil_ref()
163179
}
@@ -693,6 +709,10 @@ pub unsafe trait Element: Sized + Send {
693709

694710
/// Returns the associated type descriptor ("dtype") for the given element type.
695711
#[cfg(feature = "gil-refs")]
712+
#[deprecated(
713+
since = "0.21.0",
714+
note = "This will be replaced by `get_dtype_bound` in the future."
715+
)]
696716
fn get_dtype<'py>(py: Python<'py>) -> &'py PyArrayDescr {
697717
Self::get_dtype_bound(py).into_gil_ref()
698718
}

src/sum_products.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ where
3333
impl<'py, T> ArrayOrScalar<'py, T> for T where T: Element + FromPyObject<'py> {}
3434

3535
/// Deprecated form of [`inner_bound`]
36+
#[deprecated(
37+
since = "0.21.0",
38+
note = "will be replaced by `inner_bound` in the future"
39+
)]
3640
#[cfg(feature = "gil-refs")]
3741
pub fn inner<'py, T, DIN1, DIN2, OUT>(
3842
array1: &'py PyArray<T, DIN1>,
@@ -101,6 +105,10 @@ where
101105

102106
/// Deprecated form of [`dot_bound`]
103107
#[cfg(feature = "gil-refs")]
108+
#[deprecated(
109+
since = "0.21.0",
110+
note = "will be replaced by `dot_bound` in the future"
111+
)]
104112
pub fn dot<'py, T, DIN1, DIN2, OUT>(
105113
array1: &'py PyArray<T, DIN1>,
106114
array2: &'py PyArray<T, DIN2>,
@@ -174,6 +182,10 @@ where
174182

175183
/// Deprecated form of [`einsum_bound`]
176184
#[cfg(feature = "gil-refs")]
185+
#[deprecated(
186+
since = "0.21.0",
187+
note = "will be replaced by `einsum_bound` in the future"
188+
)]
177189
pub fn einsum<'py, T, OUT>(subscripts: &str, arrays: &[&'py PyArray<T, IxDyn>]) -> PyResult<OUT>
178190
where
179191
T: Element,
@@ -221,6 +233,10 @@ where
221233

222234
/// Deprecated form of [`einsum_bound!`][crate::einsum_bound!]
223235
#[cfg(feature = "gil-refs")]
236+
#[deprecated(
237+
since = "0.21.0",
238+
note = "will be replaced by `einsum_bound!` in the future"
239+
)]
224240
#[macro_export]
225241
macro_rules! einsum {
226242
($subscripts:literal $(,$array:ident)+ $(,)*) => {{

0 commit comments

Comments
 (0)