Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement reset! for FIRInterpolator and tests #626

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DSP"
uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2"
version = "0.8.1"
version = "0.8.2"

[deps]
Bessels = "0e736298-9ec6-45e8-9647-e4fc86a2fe38"
Expand Down
5 changes: 2 additions & 3 deletions src/Filters/stream_filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,11 @@ setphase!(self::FIRFilter, ϕ::Real) = setphase!(self.kernel, ϕ)
# reset! filter and its kernel to an initial state
#

# Generic case for FIRInterpolator and FIRStandard
function reset!(kernel::FIRKernel)
function reset!(kernel::FIRStandard)
kernel
end

function reset!(kernel::FIRRational)
function reset!(kernel::Union{FIRRational,FIRInterpolator})
kernel.ϕIdx = 1
kernel.inputDeficit = 1
kernel
Expand Down
5 changes: 3 additions & 2 deletions test/resample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ end
@test y_jl ≈ expected_result_3d

# check buffer is resized properly (vs old implementation)
for dims in 1:3
# also test that FIRInterpolator/Decimator is reset!ed properly (issue #625)
for dims in 1:3, rate in (1.2, 0.8, 4, 2//1, 1//2)
A = rand(3, 3, 3)
@test resample(A, 1.2; dims) == mapslices(v -> resample(v, 1.2), A; dims)
@test resample(A, rate; dims) == mapslices(v -> resample(v, rate), A; dims)
end
end

Expand Down
Loading