Skip to content

Commit

Permalink
Fix a few deprecations (JuliaDSP#200)
Browse files Browse the repository at this point in the history
* Avoid implicit scalar broadcasting in setindex!

* Add `using` for `eig` and `svd` to `Estimation` module

Also drop a spurious `import` statement.

* Move two previously global variables into a testset in LPC tests
  • Loading branch information
martinholters authored May 9, 2018
1 parent a5116cb commit b358239
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Filters/filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function fftfilt(b::AbstractVector{T}, x::AbstractArray{T},
# FFT of filter
filterft = similar(tmp2)
copyto!(tmp1, b)
tmp1[nb+1:end] = zero(T)
tmp1[nb+1:end] .= zero(T)
mul!(filterft, p1, tmp1)

# FFT of chunks
Expand All @@ -533,8 +533,8 @@ function fftfilt(b::AbstractVector{T}, x::AbstractArray{T},
xstart = off - nb + npadbefore + 1
n = min(nfft - npadbefore, nx - xstart + 1)

tmp1[1:npadbefore] = zero(T)
tmp1[npadbefore+n+1:end] = zero(T)
tmp1[1:npadbefore] .= zero(T)
tmp1[npadbefore+n+1:end] .= zero(T)

copyto!(tmp1, npadbefore+1, x, colstart+xstart, n)
mul!(tmp2, p1, tmp1)
Expand Down
9 changes: 5 additions & 4 deletions src/estimation.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Estimation
import Base: *

using Compat.LinearAlgebra: eig, svd

export esprit

Expand All @@ -8,10 +9,10 @@ export esprit
ESPRIT [^Roy1986] algorithm for frequency estimation.
Estimation of Signal Parameters via Rotational Invariance Techniques
Given length N signal "x" that is the sum of p sinusoids of unknown frequencies,
estimate and return an array of the p frequencies.
# Arguments
- `x::AbstractArray`: complex length N signal array
- `M::Integer`: size of correlation matrix, must be <= N.
Expand All @@ -21,7 +22,7 @@ estimate and return an array of the p frequencies.
For faster execution (due to smaller SVD), use small M or small N-M
- `p::Integer`: number of sinusoids to estimate.
- `Fs::Float64`: sampling frequency, in Hz.
# Returns
length p real array of frequencies in units of Hz.
Expand Down
4 changes: 2 additions & 2 deletions test/filter_conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ using DSP, Compat, Compat.Test, FilterTestHelpers, Polynomials

# And with only poles (no zeros)
m_sos_only_poles = copy(m_sos_full)
m_sos_only_poles[:, 1:2] = 0
m_sos_only_poles[:, 3] = 1
m_sos_only_poles[:, 1:2] .= 0
m_sos_only_poles[:, 3] .= 1
@test m_sos_only_poles sosfilter_to_matrix(convert(SecondOrderSections, ZeroPoleGain(Float64[], p, k)))

# Test that a filter with repeated zeros is handled properly
Expand Down
6 changes: 3 additions & 3 deletions test/lpc.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Filter some noise, try to learn the coefficients
coeffs = [1, .5, .3, .2]
x = filt([1], coeffs, randn(50000))

@testset "$method" for method in (LPCBurg(), LPCLevinson())
coeffs = [1, .5, .3, .2]
x = filt([1], coeffs, randn(50000))

# Analyze the filtered noise, attempt to reconstruct the coefficients above
ar, e = lpc(x[1000:end], length(coeffs)-1, method)

Expand Down

0 comments on commit b358239

Please sign in to comment.