@@ -6,7 +6,7 @@ use df::{Complex32, DFState, UNIT_NORM_INIT};
66use ndarray:: { Array1 , Array2 , Array3 , Array4 , ArrayD , ArrayView4 , Axis , ShapeError } ;
77use numpy:: {
88 IntoPyArray , PyArray1 , PyArray2 , PyArray3 , PyArrayDyn , PyReadonlyArray1 , PyReadonlyArray2 ,
9- PyReadonlyArray3 , PyReadonlyArrayDyn ,
9+ PyReadonlyArray3 , PyReadonlyArrayDyn , PyUntypedArrayMethods , PyArrayMethods ,
1010} ;
1111use pyo3:: exceptions:: { PyRuntimeError , PyValueError } ;
1212use pyo3:: prelude:: * ;
@@ -68,7 +68,7 @@ impl DF {
6868 self . state . analysis ( ichunk, ochunk)
6969 }
7070 }
71- Ok ( output. into_pyarray ( py) )
71+ Ok ( output. into_pyarray_bound ( py) )
7272 }
7373
7474 fn synthesis < ' py > (
@@ -84,7 +84,7 @@ impl DF {
8484 let out_steps = freq_steps * frame_size;
8585 let mut output = Array2 :: < f32 > :: zeros ( ( channels, out_steps) ) ;
8686
87- let mut input = unsafe { input. as_array_mut ( ) } ;
87+ let mut input = unsafe { input. as_array ( ) } ;
8888 for ( mut in_ch, mut out_ch) in
8989 input. axis_iter_mut ( Axis ( 0 ) ) . zip ( output. axis_iter_mut ( Axis ( 0 ) ) )
9090 {
@@ -103,15 +103,15 @@ impl DF {
103103 self . state . synthesis ( ichunk, ochunk) ;
104104 }
105105 }
106- Ok ( output. into_pyarray ( py) )
106+ Ok ( output. into_pyarray_bound ( py) )
107107 }
108108
109109 fn erb_widths < ' py > ( & self , py : Python < ' py > ) -> PyResult < & ' py PyArray1 < usize > > {
110- Ok ( self . state . erb . clone ( ) . into_pyarray ( py) )
110+ Ok ( self . state . erb . clone ( ) . into_py ( py) )
111111 }
112112
113113 fn fft_window < ' py > ( & self , py : Python < ' py > ) -> PyResult < & ' py PyArray1 < f32 > > {
114- Ok ( self . state . window . clone ( ) . into_pyarray ( py) )
114+ Ok ( self . state . window . clone ( ) . into_py ( py) )
115115 }
116116
117117 fn sr ( & self ) -> usize {
@@ -136,7 +136,7 @@ impl DF {
136136}
137137
138138#[ pymodule]
139- fn libdf ( _py : Python , m : & PyModule ) -> PyResult < ( ) > {
139+ fn libdf ( _py : Python , m : & Bound < T > ) -> PyResult < ( ) > {
140140 m. add_class :: < DF > ( ) ?;
141141
142142 #[ pyfn( m) ]
@@ -188,7 +188,7 @@ fn libdf(_py: Python, m: &PyModule) -> PyResult<()> {
188188 . to_py_err ( ) ?,
189189 _ => output. into_dimensionality ( ) . to_py_err ( ) ?,
190190 } ;
191- Ok ( output. into_pyarray ( py) )
191+ Ok ( output. into_pyarray_bound ( py) )
192192 }
193193
194194 #[ pyfn( m) ]
@@ -246,7 +246,7 @@ fn libdf(_py: Python, m: &PyModule) -> PyResult<()> {
246246 . to_py_err ( ) ?,
247247 _ => output. into_dimensionality ( ) . to_py_err ( ) ?,
248248 } ;
249- Ok ( output. into_pyarray ( py) )
249+ Ok ( output. into_pyarray_bound ( py) )
250250 }
251251
252252 #[ pyfn( m) ]
@@ -263,14 +263,14 @@ fn libdf(_py: Python, m: &PyModule) -> PyResult<()> {
263263 if let Some ( state) = state {
264264 transforms:: erb_norm (
265265 & mut erb. view_mut ( ) ,
266- Some ( unsafe { state. as_array_mut ( ) } . to_owned ( ) ) ,
266+ Some ( unsafe { state. as_array ( ) } . to_owned ( ) ) ,
267267 alpha,
268268 )
269269 . to_py_err ( ) ?;
270270 } else {
271271 transforms:: erb_norm ( & mut erb. view_mut ( ) , None , alpha) . to_py_err ( ) ?;
272272 } ;
273- Ok ( erb. into_owned ( ) . into_pyarray ( py) )
273+ Ok ( erb. into_owned ( ) . into_pyarray_bound ( py) )
274274 }
275275
276276 #[ pyfn( m) ]
@@ -287,14 +287,14 @@ fn libdf(_py: Python, m: &PyModule) -> PyResult<()> {
287287 if let Some ( state) = state {
288288 transforms:: unit_norm (
289289 & mut spec. view_mut ( ) ,
290- Some ( unsafe { state. as_array_mut ( ) } . to_owned ( ) ) ,
290+ Some ( unsafe { state. as_array ( ) } . to_owned ( ) ) ,
291291 alpha,
292292 )
293293 . to_py_err ( ) ?;
294294 } else {
295295 transforms:: unit_norm ( & mut spec. view_mut ( ) , None , alpha) . to_py_err ( ) ?;
296296 } ;
297- Ok ( spec. into_pyarray ( py) )
297+ Ok ( spec. into_pyarray_bound ( py) )
298298 }
299299
300300 #[ pyfn( m) ]
@@ -303,7 +303,7 @@ fn libdf(_py: Python, m: &PyModule) -> PyResult<()> {
303303 let arr = Array1 :: < f32 > :: linspace ( UNIT_NORM_INIT [ 0 ] , UNIT_NORM_INIT [ 1 ] , num_freq_bins)
304304 . into_shape ( [ 1 , num_freq_bins] )
305305 . to_py_err ( ) ?;
306- Ok ( arr. into_pyarray ( py) )
306+ Ok ( arr. into_pyarray_bound ( py) )
307307 }
308308
309309 Ok ( ( ) )
0 commit comments