FFTW.jl
FFTW.jl copied to clipboard
improve error message for plan_ifft!(v::Vector{T<:Real})
From https://github.com/JuliaLang/julia/issues/19087
This confused me for a second:
julia> plan_ifft!(rand(10)) ERROR: MethodError: `plan_bfft!` has no method matching plan_bfft!(::Array{Float64,1}, ::UnitRange{Int64}) Closest candidates are: plan_bfft!(::Any, ::Any, ::Any) plan_bfft!(::Any, ::Any, ::Any, ::Any) plan_bfft!{T<:Union{Complex{Float32},Complex{Float64}},N}(::Union{DenseArray{T<:Union{Complex{Float32},Complex{Float64}},N},SubArray{T<:Union{Complex{Float32},Complex{Float64}},N,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64}}}},LD}}, ::Any) ... in plan_ifft! at dft.jl:277 in plan_ifft! at dft.jl:38
I think
plan_ifft!(v::Vector{T<:Real})
should be overriden to give an error message saying that the input has to be complex.
This would really go into AbstractFFTs.jl, since that is where the promotion from real to complex arrays happens.
I'm not convinced that the current MethodError isn't fine, though. At some point Julia users need to learn to read MethodErrors, and the plan_fft
functions are usually for more advanced users.
Alternatively, the plan_fft
functions could also auto-promote real arrays to complex ones, like the fft
and bfft
functions already do.