MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_psd_oversampling

Function test_psd_oversampling

lib/matplotlib/tests/test_mlab.py:1027–1037  ·  view source on GitHub ↗

Test the case len(x) < NFFT for psd().

()

Source from the content-addressed store, hash-verified

1025
1026
1027def test_psd_oversampling():
1028 """Test the case len(x) < NFFT for psd()."""
1029 u = np.array([0, 1, 2, 3, 1, 2, 1])
1030 dt = 1.0
1031 Su = np.abs(np.fft.fft(u) * dt)**2 / (dt * u.size)
1032 P, f = mlab.psd(u, NFFT=u.size*2, Fs=1/dt, window=mlab.window_none,
1033 detrend=mlab.detrend_none, noverlap=0, pad_to=None,
1034 scale_by_freq=None,
1035 sides='onesided')
1036 Su_1side = np.append([Su[0]], Su[1:4] + Su[4:][::-1])
1037 assert_almost_equal(np.sum(P), np.sum(Su_1side)) # same energy

Callers

nothing calls this directly

Calls 1

psdMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…