Skip to content

Commit

Permalink
Test welch_pgram deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Nov 7, 2024
1 parent ea8fcdc commit af61887
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/periodograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,36 @@ end
4.0,
13.656854249492380]
@test power(periodogram(data, onesided=false)) data0
@test power(@test_deprecated welch_pgram(data, length(data), 0, onesided=false)) data0
@test power(welch_pgram(data, length(data), 0, onesided=false, window=nothing)) data0
@test power(spectrogram(data, length(data), 0, onesided=false)) data0
@test power(periodogram(complex.([data;], [data;]), onesided=false)) data0*2
@test power(@test_deprecated welch_pgram(complex.([data;], [data;]), length(data), 0, onesided=false)) data0*2
@test power(welch_pgram(complex.([data;], [data;]), length(data), 0, onesided=false, window=nothing)) data0*2
@test power(spectrogram(complex.([data;], [data;]), length(data), 0, onesided=false)) data0*2

# # ~~~~~~~~ Tests with no window ~~~~~~~~~~~~~~~~~~~
# Matlab: p = pwelch(0:7, [1, 1], 0, 2, 1, 'twosided')
expected = Float64[34.5, 0.5]
@test power(@test_deprecated welch_pgram(data, 2, 0; onesided=false)) expected
@test power(welch_pgram(data, 2, 0; onesided=false, window=nothing)) expected
@test mean(power(spectrogram(data, 2, 0; onesided=false)), dims=2) expected

# Matlab: p = pwelch(0:7, [1, 1, 1], 0, 3, 1, 'twosided')
expected = Float64[25.5, 1.0, 1.0]
@test power(@test_deprecated welch_pgram(data, 3, 0; onesided=false)) expected
@test power(welch_pgram(data, 3, 0; onesided=false, window=nothing)) expected
@test mean(power(spectrogram(data, 3, 0; onesided=false)), dims=2) expected

# Matlab: p = pwelch(0:7, [1, 1, 1], 1, 3, 1, 'twosided')
expected = Float64[35.0, 1.0, 1.0]
@test power(@test_deprecated welch_pgram(data, 3, 1; onesided=false)) expected
@test power(welch_pgram(data, 3, 1; onesided=false, window=nothing)) expected
@test mean(power(spectrogram(data, 3, 1; onesided=false)), dims=2) expected

# Matlab: p = pwelch(0:7, [1, 1, 1, 1], 1, 4, 1, 'twosided')
expected = Float64[45, 2, 1, 2]
@test power(@test_deprecated welch_pgram(data, 4, 1; onesided=false)) expected
@test power(welch_pgram(data, 4, 1; onesided=false, window=nothing)) expected
@test mean(power(spectrogram(data, 4, 1; onesided=false)), dims=2) expected

Expand Down Expand Up @@ -189,6 +195,7 @@ end
2
]
@test power(periodogram(data; nfft=32)) expected
@test power(@test_deprecated welch_pgram(data, length(data), 0; nfft=32)) expected
@test power(welch_pgram(data, length(data), 0; nfft=32, window=nothing)) expected
@test power(spectrogram(data, length(data), 0; nfft=32)) expected

Expand Down

0 comments on commit af61887

Please sign in to comment.