@@ -803,6 +803,18 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
803803 self . as_borrowed ( ) . to_vec ( )
804804 }
805805
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+
806818 /// Construct a NumPy array from a [`ndarray::ArrayBase`].
807819 ///
808820 /// This method allocates memory in Python's heap via the NumPy API,
@@ -811,21 +823,21 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
811823 /// # Example
812824 ///
813825 /// ```
814- /// use numpy::PyArray;
826+ /// use numpy::{ PyArray, PyArrayMethods} ;
815827 /// use ndarray::array;
816828 /// use pyo3::Python;
817829 ///
818830 /// 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]]);
820832 ///
821833 /// assert_eq!(pyarray.readonly().as_array(), array![[1, 2], [3, 4]]);
822834 /// });
823835 /// ```
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 >
825837 where
826838 S : Data < Elem = T > ,
827839 {
828- ToPyArray :: to_pyarray_bound ( arr, py) . into_gil_ref ( )
840+ ToPyArray :: to_pyarray_bound ( arr, py)
829841 }
830842
831843 /// Get an immutable borrow of the NumPy array
0 commit comments