Code: multispec input vector eltype
Issue #14
closed
The multivariate version of multispec
errors if one does not pass two Vector{Float64}
s because this case is not handled in the code. Add a test for this and fix it. For example, pass two Vector{Float32}
s, or vectors of different eltype
.
julia> using Multitaper
julia> multispec(rand(Float32, 100), rand(Float32, 100))
ERROR: UndefVarError: halffreq not defined
Stacktrace:
[1] multispec(::Array{Float32,1}, ::Array{Float32,1}; outp::Symbol, NW::Float64, K::Int64, offset::Int64, dt::Float64, ctr::Bool, pad::Float64, dpVec::Nothing, guts::Bool, jk::Bool, Tsq::Nothing, alph::Float64) at /Users/nowacki/.julia/dev/Multitaper/src/Multivariate.jl:67
[2] multispec(::Array{Float32,1}, ::Array{Float32,1}) at /Users/nowacki/.julia/dev/Multitaper/src/Multivariate.jl:28
[3] top-level scope at REPL[2]:1
Document if you want to enforce that both input vectors must be of the same type, and have element type Float64
. (Otherwise one just gets MethodError
.) If not, consider promoting to the larger element type.
julia> multispec(rand(Float32, 100), rand(100))
ERROR: MethodError: no method matching multispec(::Array{Float32,1}, ::Array{Float64,1})
Closest candidates are:
multispec(::Union{Array{T,1}, Ecoef}, ::Union{Array{T,1}, Ecoef}; outp, NW, K, offset, dt, ctr, pad, dpVec, guts, jk, Tsq, alph) where T at /Users/nowacki/.julia/dev/Multitaper/src/Multivariate.jl:24
multispec(::Any; NW, K, dt, ctr, pad, dpVec, egval, guts, a_weight, Ftest, highres, jk, Tsq, alph) at /Users/nowacki/.julia/dev/Multitaper/src/Univariate.jl:220
Stacktrace:
[1] top-level scope at REPL[3]:1
Comments (3)
-
repo owner -
reporter Thanks—this addresses my comment and can be closed.
-
repo owner - changed status to closed
- Log in to comment
See lines 83+ of this commit. The vectors can have different types. Thanks.