Skip to content

Commit dd53aeb

Browse files
committed
Fix lfilter for 1D signal
Had to step into python to actually see what the slicing was doing...
1 parent 3d9e0f8 commit dd53aeb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sci-rs/src/signal/filter/lfilter.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ where
104104
unimplemented!()
105105
};
106106

107-
let mut x: ArrayBase<S, _> = x.into();
108107
// We make a best effort to convert into appropriate axis object.
109108
let (axis, axis_inner): (Axis, usize) = {
110-
let axis_inner: isize = axis.unwrap_or(-1).into();
109+
let axis_inner: isize = axis.unwrap_or(-1);
111110
if axis_inner >= 0 {
112111
(Axis(axis_inner as usize), axis_inner as usize)
113112
} else {
@@ -131,16 +130,15 @@ where
131130
// np.convolve uses full mode, but is eventually slices out with
132131
// ```py
133132
// ind = out_full.ndim * [slice(None)] # creates the "[:, :, ..., :]" slicer
134-
// ind[axis] = slice(out_full.shape[axis] - len(b) + 1, None)
135-
// # [out_full.shape[..] - len(b) + 1 : None]
133+
// ind[axis] = slice(out_full.shape[axis] - len(b) + 1) # [:out_full.shape[..] - len(b) + 1]
136134
// ```
137135
use sci_rs_core::num_rs::{convolve, ConvolveMode};
138136
let out_full = convolve(y, (&b).into(), ConvolveMode::Full).unwrap();
139137
let out_full_slice: ArrayView1<T> = out_full
140138
.slice(
141139
SliceInfo::try_from([SliceInfoElem::Slice {
142-
start: (out_dim_inner[axis_inner] - b.len()) as isize,
143-
end: None,
140+
start: 0,
141+
end: Some(out_dim_inner[axis_inner] as isize),
144142
step: 1,
145143
}])
146144
.unwrap(),

0 commit comments

Comments
 (0)