From 69abc408a8d3eaeba8e3999b8c3d8f7a87150f24 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Thu, 28 Sep 2017 09:49:11 +0200 Subject: [PATCH] Fix FFTW related warning on Julia 0.6 (#179) Avoid `using FFTW` on Julia 0.6, as the FFTW package does not define a module there, leading a warning about failed precompilation. --- src/DSP.jl | 6 ++++-- src/util.jl | 13 ++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/DSP.jl b/src/DSP.jl index 320ab45ed..dd7ca3ead 100644 --- a/src/DSP.jl +++ b/src/DSP.jl @@ -6,9 +6,11 @@ module DSP # This macro will be called in each submodule herein to do the appropriate imports macro importffts() quote - using AbstractFFTs, FFTW - importall AbstractFFTs, FFTW + using AbstractFFTs + importall AbstractFFTs if VERSION >= v"0.7.0-DEV.602" + using FFTW + importall FFTW import AbstractFFTs: fftshift, ifftshift import FFTW: plan_fft, plan_fft!, plan_rfft, plan_brfft, plan_irfft, plan_bfft, plan_bfft!, fft, fft!, ifft, ifft!, irfft, bfft, bfft! diff --git a/src/util.jl b/src/util.jl index 83469309a..33734567a 100644 --- a/src/util.jl +++ b/src/util.jl @@ -1,6 +1,5 @@ module Util using ..DSP: @importffts -import FFTW: fftwReal, fftwComplex, fftwNumber import Base: * @importffts @@ -49,7 +48,7 @@ function unwrap(m::Array{T}, args...; kwargs...) where T<:AbstractFloat unwrap!(copy(m), args...; kwargs...) end -function hilbert(x::StridedVector{T}) where T<:fftwReal +function hilbert(x::StridedVector{T}) where T<:FFTW.fftwReal # Return the Hilbert transform of x (a real signal). # Code inspired by Scipy's implementation, which is under BSD license. N = length(x) @@ -104,18 +103,18 @@ end ## FFT TYPES # Get the input element type of FFT for a given type -fftintype(::Type{T}) where {T<:fftwNumber} = T +fftintype(::Type{T}) where {T<:FFTW.fftwNumber} = T fftintype(::Type{T}) where {T<:Real} = Float64 fftintype(::Type{T}) where {T<:Complex} = Complex128 # Get the return element type of FFT for a given type -fftouttype(::Type{T}) where {T<:fftwComplex} = T -fftouttype(::Type{T}) where {T<:fftwReal} = Complex{T} +fftouttype(::Type{T}) where {T<:FFTW.fftwComplex} = T +fftouttype(::Type{T}) where {T<:FFTW.fftwReal} = Complex{T} fftouttype(::Type{T}) where {T<:Union{Real,Complex}} = Complex128 # Get the real part of the return element type of FFT for a given type -fftabs2type(::Type{Complex{T}}) where {T<:fftwReal} = T -fftabs2type(::Type{T}) where {T<:fftwReal} = T +fftabs2type(::Type{Complex{T}}) where {T<:FFTW.fftwReal} = T +fftabs2type(::Type{T}) where {T<:FFTW.fftwReal} = T fftabs2type(::Type{T}) where {T<:Union{Real,Complex}} = Float64 ## FREQUENCY VECTOR