Skip to content

Commit ced09b0

Browse files
committed
test warnings, fix kwargs
1 parent 191fb51 commit ced09b0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/multitaper.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,14 @@ struct MTCrossSpectraConfig{T,T1,T2,T3,T4,F,T5,T6,C<:MTConfig{T}}
440440
) where {T,T1,T2,T3,T4,F,T5,T6,C<:MTConfig{T}}
441441
check_onesided_real(mt_config) # this restriction is artificial; the code needs to be generalized
442442
if n_channels > mt_config.n_samples && !override_warn
443-
Base.depwarn("n_channels > n_samples; this is likely a mistake.
443+
Base.depwarn(
444+
"""
445+
n_channels > n_samples; this is likely a mistake.
444446
From v0.9 onwards, each column is interpreted as a separate signal,
445447
whereas in v0.8 and earlier, each row was interpreted as a separate signal.
446-
To suppress this warning, pass `override_warn=true` to `MTCrossSpectraConfig`.",
448+
To suppress this warning, pass `override_warn=true` as a keyword argument to
449+
`MTCoherenceConfig`, `MTCrossSpectraConfig`, `mt_coherence`, or `mt_cross_power_spectra`.
450+
""",
447451
:mt_cross_power_spectra; force=true)
448452
end
449453
return new{T,T1,T2,T3,T4,F,T5,T6,C}(
@@ -484,9 +488,10 @@ Returns a `CrossPowerSpectra` object.
484488
function MTCrossSpectraConfig{T}(n_channels, n_samples; fs=1, demean=false,
485489
freq_range=nothing,
486490
ensure_aligned = T == Float32 || T == Complex{Float32},
491+
override_warn=false,
487492
kwargs...) where {T}
488493
mt_config = MTConfig{T}(n_samples; fs, kwargs...)
489-
return MTCrossSpectraConfig{T}(n_channels, mt_config; demean, freq_range, ensure_aligned)
494+
return MTCrossSpectraConfig{T}(n_channels, mt_config; demean, freq_range, ensure_aligned, override_warn)
490495
end
491496

492497
# extra method to ensure it's ok to pass the redundant type parameter {T}

test/multitaper.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ end
326326
@test_throws DimensionMismatch mt_cross_power_spectra!(similar(out, size(out, 1) + 1, size(out, 2), size(out, 3)), signal, config)
327327
@test_throws DimensionMismatch mt_cross_power_spectra!(out, vcat(signal, signal), config)
328328

329+
# test warnings for n_channels > n_samples
330+
@test_warn "n_channels > n_samples" mt_cross_power_spectra(rand(10, 100))
331+
@test_warn "n_channels > n_samples" mt_coherence(rand(10, 100))
332+
@test_nowarn mt_cross_power_spectra(rand(10, 100); override_warn=true)
333+
@test_nowarn mt_coherence(rand(10, 100); override_warn=true)
329334
end
330335

331336

0 commit comments

Comments
 (0)