@@ -803,6 +803,18 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
803
803
self . as_borrowed ( ) . to_vec ( )
804
804
}
805
805
806
+ /// Deprecated form of [`PyArray<T, D>::from_array_bound`]
807
+ #[ deprecated(
808
+ since = "0.21.0" ,
809
+ note = "will be replaced by PyArray::from_array_bound in the future"
810
+ ) ]
811
+ pub fn from_array < ' py , S > ( py : Python < ' py > , arr : & ArrayBase < S , D > ) -> & ' py Self
812
+ where
813
+ S : Data < Elem = T > ,
814
+ {
815
+ Self :: from_array_bound ( py, arr) . into_gil_ref ( )
816
+ }
817
+
806
818
/// Construct a NumPy array from a [`ndarray::ArrayBase`].
807
819
///
808
820
/// This method allocates memory in Python's heap via the NumPy API,
@@ -811,21 +823,21 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
811
823
/// # Example
812
824
///
813
825
/// ```
814
- /// use numpy::PyArray;
826
+ /// use numpy::{ PyArray, PyArrayMethods} ;
815
827
/// use ndarray::array;
816
828
/// use pyo3::Python;
817
829
///
818
830
/// Python::with_gil(|py| {
819
- /// let pyarray = PyArray::from_array (py, &array![[1, 2], [3, 4]]);
831
+ /// let pyarray = PyArray::from_array_bound (py, &array![[1, 2], [3, 4]]);
820
832
///
821
833
/// assert_eq!(pyarray.readonly().as_array(), array![[1, 2], [3, 4]]);
822
834
/// });
823
835
/// ```
824
- pub fn from_array < ' py , S > ( py : Python < ' py > , arr : & ArrayBase < S , D > ) -> & ' py Self
836
+ pub fn from_array_bound < ' py , S > ( py : Python < ' py > , arr : & ArrayBase < S , D > ) -> Bound < ' py , Self >
825
837
where
826
838
S : Data < Elem = T > ,
827
839
{
828
- ToPyArray :: to_pyarray_bound ( arr, py) . into_gil_ref ( )
840
+ ToPyArray :: to_pyarray_bound ( arr, py)
829
841
}
830
842
831
843
/// Get an immutable borrow of the NumPy array
0 commit comments