Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4165d7a

Browse files
authored
Merge pull request #10019 from jklymak/tst-mlab-cohere
TST: test mlab cohere
2 parents 435520f + 07eebc8 commit 4165d7a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/matplotlib/tests/test_mlab.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,20 @@ def test_psd_windowarray_equal(self):
21362136
assert_allclose(speca, specb, atol=1e-08)
21372137

21382138

2139+
# extra test for cohere...
2140+
def test_cohere():
2141+
N = 1024
2142+
np.random.seed(19680801)
2143+
x = np.random.randn(N)
2144+
# phase offset
2145+
y = np.roll(x, 20)
2146+
# high-freq roll-off
2147+
y = np.convolve(y, np.ones(20) / 20., mode='same')
2148+
cohsq, f = mlab.cohere(x, y, NFFT=256, Fs=2, noverlap=128)
2149+
assert_allclose(np.mean(cohsq), 0.837, atol=1.e-3)
2150+
assert np.isreal(np.mean(cohsq))
2151+
2152+
21392153
def test_griddata_linear():
21402154
# z is a linear function of x and y.
21412155
def get_z(x, y):

0 commit comments

Comments
 (0)