From d5bd1964a34590876e4f6140bde76b9ba30c47af Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 6 Jul 2018 14:50:10 +0200 Subject: [PATCH] Fix a few deprecations on Julia 0.7 (#207) * Use `eigen` and `eigen!` on newer Julia * Use single-argument `eval` * Replace `atan2` with two-argument `atan` --- REQUIRE | 2 +- src/Filters/response.jl | 2 +- src/estimation.jl | 12 ++++++++++-- src/windows.jl | 10 ++++++++-- test/runtests.jl | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/REQUIRE b/REQUIRE index 69d6e29cd..8095b0d4a 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.6 -Compat 0.63 +Compat 0.69 Polynomials 0.1.0 Reexport SpecialFunctions diff --git a/src/Filters/response.jl b/src/Filters/response.jl index 08189aff6..050dcfacc 100644 --- a/src/Filters/response.jl +++ b/src/Filters/response.jl @@ -54,7 +54,7 @@ or frequencies `w` in radians/sample. """ function phasez(filter::FilterCoefficients, w = Compat.range(0, stop=π, length=250)) h = freqz(filter, w) - unwrap(-atan2.(imag(h), real(h)); dims=ndims(h)) + unwrap(-atan.(imag(h), real(h)); dims=ndims(h)) end diff --git a/src/estimation.jl b/src/estimation.jl index ff8746422..d561a6668 100644 --- a/src/estimation.jl +++ b/src/estimation.jl @@ -1,6 +1,10 @@ module Estimation -using Compat.LinearAlgebra: eig, svd +if VERSION < v"0.7.0-DEV.5211" + using Compat.LinearAlgebra: eig, svd +else + using LinearAlgebra: eigen, svd +end export esprit @@ -33,7 +37,11 @@ function esprit(x::AbstractArray, M::Integer, p::Integer, Fs::Real=1.0) N = length(x) X = x[ (1:M) .+ (0:N-M)' ] U,s,V = svd(X) - D,_ = eig( U[1:end-1,1:p] \ U[2:end,1:p] ) + @static if VERSION < v"0.7.0-DEV.5211" + D,_ = eig( U[1:end-1,1:p] \ U[2:end,1:p] ) + else + D,_ = eigen( U[1:end-1,1:p] \ U[2:end,1:p] ) + end angle.(D)*Fs/2π end diff --git a/src/windows.jl b/src/windows.jl index b1d366ad2..ef38a1d55 100644 --- a/src/windows.jl +++ b/src/windows.jl @@ -4,7 +4,11 @@ using ..Util import SpecialFunctions: besseli import Compat using Compat: copyto!, undef -using Compat.LinearAlgebra: Diagonal, SymTridiagonal, eigfact! +if VERSION < v"0.7.0-DEV.5211" + using Compat.LinearAlgebra: Diagonal, SymTridiagonal, eigfact! +else + using LinearAlgebra: Diagonal, SymTridiagonal, eigen! +end @importffts export rect, @@ -193,8 +197,10 @@ function dpss(n::Int, nw::Real, ntapers::Int=ceil(Int, 2*nw)-1) # Get tapers @static if VERSION < v"0.7.0-DEV.3159" eigvec = eigfact!(mat, n-ntapers+1:n)[:vectors] - else + elseif VERSION < v"0.7.0-DEV.5211" eigvec = eigfact!(mat, n-ntapers+1:n).vectors + else + eigvec = eigen!(mat, n-ntapers+1:n).vectors end v = Compat.reverse(eigvec::Matrix{Float64}, dims=2) diff --git a/test/runtests.jl b/test/runtests.jl index 2d88e2f5d..3be2a451e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,5 +5,5 @@ testfiles = [ "dsp.jl", "util.jl", "windows.jl", "filter_conversion.jl", "periodograms.jl", "resample.jl", "lpc.jl", "estimation.jl", "unwrap.jl"] for testfile in testfiles - eval(@__MODULE__, :(@testset $testfile begin include($testfile) end)) + eval(:(@testset $testfile begin include($testfile) end)) end