Code: mdmultispec(t, x[, y]): Remove type assertions in keyword arguments
mdmultispec(t, x, y)
and mdmultispec(t, ::Matrix)
both have typed keyword arguments. Consider removing or relaxing them.
For instance, is there any reason not to allow an Integer
for bw
?
julia> mdmultispec(t, x, y, bw=3)
ERROR: TypeError: in keyword argument bw, expected Float64, got a value of type Int64
Stacktrace:
[1] top-level scope at REPL[8]:1
Comments (3)
-
repo owner -
reporter I realise that I don’t know what the
bw
argument actually means, but I feel it probably needs to be in the range0 < bw < 1
. In that case, perhaps the right thing to do is check for this and give the user an informative error message?My attempt at checking for the update:
julia> let n = 20, t = sort(rand(n)), x = randn(n), y = randn(n) mdmultispec(t, x, y, bw=3) end ┌ Warning: Adjusting nev from 119 to 19 └ @ Arpack ~/.julia/packages/Arpack/o35I5/src/Arpack.jl:82 ERROR: BoundsError: attempt to access 20×19 Array{Float64,2} at index [1:20, 21] Stacktrace: [1] throw_boundserror(::Array{Float64,2}, ::Tuple{Base.Slice{Base.OneTo{Int64}},Int64}) at ./abstractarray.jl:541 [2] checkbounds at ./abstractarray.jl:506 [inlined] [3] _getindex at ./multidimensional.jl:742 [inlined] [4] getindex(::Array{Float64,2}, ::Function, ::Int64) at ./abstractarray.jl:1060 [5] mdslepian(::Int64, ::Int64, ::Array{Float64,1}) at /Users/nowacki/.julia/dev/Multitaper/src/MDmwps.jl:369 [6] mdmultispec(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}; bw::Int64, k::Int64, dt::Float64, jk::Bool, nz::Float64, Ftest::Bool, lambdau::Nothing) at /Users/nowacki/.julia/dev/Multitaper/src/MDmwps.jl:213 [7] top-level scope at REPL[24]:2
I didn’t get a sense of what the bandwidth was supposed to be (what are its units, or is it a proportion of the Nyquist frequency, for instance) from the docs, but I am not an expert in this field by any means and it may not be necessary to document this more precisely.
-
repo owner Good question. The bandwidth is sometimes given by stating the time-bandwidth product,
NW
for unit sampling, which is given in units of the Rayleigh resolution (1/N delta t, where N is the number of samples and delta t is the sampling interval). However, in this particular function,bw
is actually dependent on the delta-t for the time series, and so is not restricted. - Log in to comment
[This commit}(https://bitbucket.org/clhaley/multitaper.jl/commits/5d141b5d0bfd52496e4594633f9b457efa517d3c) attempts to address this.