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

resample with dims is broken #625

Closed
mchitre opened this issue Feb 8, 2025 · 1 comment · Fixed by #626
Closed

resample with dims is broken #625

mchitre opened this issue Feb 8, 2025 · 1 comment · Fixed by #626

Comments

@mchitre
Copy link

mchitre commented Feb 8, 2025

Resample of a 1D array without specifying dims works, but specifying dims=1 breaks it.

MWE:

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
(jl_45BPGW) pkg> st DSP
  [717857b8] DSP v0.8.1

julia> using DSP

julia> x = randn(100);

julia> resample(x, 4) |> length
400

julia> resample(x, 4; dims=1) |> length
ERROR: AssertionError: Length of resampled output different from expectation.
Stacktrace:
 [1] checked_resample_output!
   @ ~/.julia/packages/DSP/VbLcO/src/Filters/stream_filt.jl:719 [inlined]
 [2] (::DSP.Filters.var"#58#59"{FIRFilter{DSP.Filters.FIRInterpolator{Float64}, Float64}, Int64, Vector{Float64}, Vector{Float64}, Int64})(v::Vector{Float64})
   @ DSP.Filters ~/.julia/packages/DSP/VbLcO/src/Filters/stream_filt.jl:774
 [3] mapslices(f::DSP.Filters.var"#58#59"{FIRFilter{DSP.Filters.FIRInterpolator{Float64}, Float64}, Int64, Vector{Float64}, Vector{Float64}, Int64}, A::Vector{Float64}; dims::Int64)
   @ Base ./abstractarray.jl:3281
 [4] mapslices
   @ ./abstractarray.jl:3265 [inlined]
 [5] _resample!(x::Vector{Float64}, rate::Int64, sf::FIRFilter{DSP.Filters.FIRInterpolator{Float64}, Float64}; dims::Int64)
   @ DSP.Filters ~/.julia/packages/DSP/VbLcO/src/Filters/stream_filt.jl:769
 [6] _resample!
   @ ~/.julia/packages/DSP/VbLcO/src/Filters/stream_filt.jl:760 [inlined]
 [7] resample(::Vector{Float64}, ::Int64; dims::Int64)
   @ DSP.Filters ~/.julia/packages/DSP/VbLcO/src/Filters/stream_filt.jl:757
 [8] top-level scope
   @ REPL[8]:1
@wheeheee
Copy link
Member

wheeheee commented Feb 8, 2025

Oh no...I believe the underlying reason is that reset!(::FIRInterpolator) was either accidentally deleted or didn't exist. This was exposed in #623 because reset! was used in the implementation of buffered array resampling.
It looks like this can be quickly fixed in a patch. In the meantime, you could try arbitrary resampling with a rate that is a float (4.0), or just use mapslices with resample directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants