Skip to content

Commit 96f9ba4

Browse files
committed
update types
1 parent e055d5a commit 96f9ba4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pyDF/src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl DF {
4343
py: Python<'py>,
4444
input: PyReadonlyArray2<'py, f32>,
4545
reset: Option<bool>,
46-
) -> PyResult<&'py PyArray3<Complex32>> {
46+
) -> PyResult<Bound<'py, PyArray3<Complex32>>> {
4747
let frame_size = self.state.frame_size;
4848
let freq_size = self.state.freq_size;
4949
let channels = input.shape()[0];
@@ -76,15 +76,15 @@ impl DF {
7676
py: Python<'py>,
7777
input: PyReadonlyArray3<Complex32>,
7878
reset: Option<bool>,
79-
) -> PyResult<&'py PyArray2<f32>> {
79+
) -> PyResult<Bound<'py, PyArray2<f32>>> {
8080
let frame_size = self.state.frame_size;
8181
let freq_size = self.state.freq_size;
8282
let channels = input.shape()[0];
8383
let freq_steps = input.shape()[1];
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() };
87+
let mut input = unsafe { input.as_array_mut() };
8888
for (mut in_ch, mut out_ch) in
8989
input.axis_iter_mut(Axis(0)).zip(output.axis_iter_mut(Axis(0)))
9090
{
@@ -106,12 +106,12 @@ impl DF {
106106
Ok(output.into_pyarray_bound(py))
107107
}
108108

109-
fn erb_widths<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<usize>> {
110-
Ok(self.state.erb.clone().into_py(py))
109+
fn erb_widths<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyArray1<usize>>> {
110+
Ok(self.state.erb.clone().into_pyarray_bound(py))
111111
}
112112

113-
fn fft_window<'py>(&self, py: Python<'py>) -> PyResult<&'py PyArray1<f32>> {
114-
Ok(self.state.window.clone().into_py(py))
113+
fn fft_window<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyArray1<f32>>> {
114+
Ok(self.state.window.clone().into_pyarray_bound(py))
115115
}
116116

117117
fn sr(&self) -> usize {
@@ -136,7 +136,7 @@ impl DF {
136136
}
137137

138138
#[pymodule]
139-
fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
139+
fn libdf(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
140140
m.add_class::<DF>()?;
141141

142142
#[pyfn(m)]
@@ -146,7 +146,7 @@ fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
146146
input: PyReadonlyArrayDyn<Complex32>,
147147
erb_fb: PyReadonlyArray1<usize>,
148148
db: Option<bool>,
149-
) -> PyResult<&'py PyArrayDyn<f32>> {
149+
) -> PyResult<Bound<'py, PyArrayDyn<f32>>> {
150150
// Input shape [B, C, T, F]
151151
let indim = input.ndim();
152152
let input = input.as_array();
@@ -197,7 +197,7 @@ fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
197197
py: Python<'py>,
198198
input: PyReadonlyArrayDyn<f32>,
199199
erb_fb: PyReadonlyArray1<usize>,
200-
) -> PyResult<&'py PyArrayDyn<f32>> {
200+
) -> PyResult<Bound<'py, PyArrayDyn<f32>>> {
201201
// Input shape [B, C, T, E]
202202
let indim = input.ndim();
203203
let input = input.as_array();
@@ -256,7 +256,7 @@ fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
256256
erb: PyReadonlyArray3<f32>,
257257
alpha: f32,
258258
state: Option<PyReadonlyArray2<f32>>,
259-
) -> PyResult<&'py PyArray3<f32>> {
259+
) -> PyResult<Bound<'py, PyArray3<f32>>> {
260260
// Input shape [C, T, F]
261261
// State shape [C, F]
262262
let mut erb = unsafe { erb.as_array_mut() };
@@ -280,7 +280,7 @@ fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
280280
spec: PyReadonlyArray3<Complex32>,
281281
alpha: f32,
282282
state: Option<PyReadonlyArray2<f32>>,
283-
) -> PyResult<&'py PyArray3<Complex32>> {
283+
) -> PyResult<Bound<'py, PyArray3<Complex32>>> {
284284
// Input shape [C, T, F]
285285
// State shape [C, F]
286286
let mut spec = spec.as_array().to_owned();
@@ -299,7 +299,7 @@ fn libdf(_py: Python, m: &Bound<T>) -> PyResult<()> {
299299

300300
#[pyfn(m)]
301301
#[pyo3(name = "unit_norm_init")]
302-
fn unit_norm_init(py: Python, num_freq_bins: usize) -> PyResult<&PyArray2<f32>> {
302+
fn unit_norm_init(py: Python, num_freq_bins: usize) -> PyResult<Bound<PyArray2<f32>>> {
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()?;

0 commit comments

Comments
 (0)