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

Skip to content

Commit d83473d

Browse files
authored
Merge pull request #10040 from matplotlib/auto-backport-of-pr-10019
Backport PR #10019 on branch v2.1.x
2 parents 7167748 + 4217af0 commit d83473d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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)