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

Method test_psd_detrend

lib/matplotlib/tests/test_mlab.py:481–514  ·  view source on GitHub ↗
(self, make_data, detrend)

Source from the content-addressed store, hash-verified

479 [(np.zeros, mlab.detrend_mean), (np.zeros, 'mean'),
480 (np.arange, mlab.detrend_linear), (np.arange, 'linear')])
481 def test_psd_detrend(self, make_data, detrend):
482 if self.NFFT_density is None:
483 return
484 ydata = make_data(self.NFFT_density)
485 ydata1 = ydata+5
486 ydata2 = ydata+3.3
487 ydata = np.vstack([ydata1, ydata2])
488 ydata = np.tile(ydata, (20, 1))
489 ydatab = ydata.T.flatten()
490 ydata = ydata.flatten()
491 ycontrol = np.zeros_like(ydata)
492 spec_g, fsp_g = mlab.psd(x=ydata,
493 NFFT=self.NFFT_density,
494 Fs=self.Fs,
495 noverlap=0,
496 sides=self.sides,
497 detrend=detrend)
498 spec_b, fsp_b = mlab.psd(x=ydatab,
499 NFFT=self.NFFT_density,
500 Fs=self.Fs,
501 noverlap=0,
502 sides=self.sides,
503 detrend=detrend)
504 spec_c, fsp_c = mlab.psd(x=ycontrol,
505 NFFT=self.NFFT_density,
506 Fs=self.Fs,
507 noverlap=0,
508 sides=self.sides)
509 assert_array_equal(fsp_g, fsp_c)
510 assert_array_equal(fsp_b, fsp_c)
511 assert_allclose(spec_g, spec_c, atol=1e-08)
512 # these should not be almost equal
513 with pytest.raises(AssertionError):
514 assert_allclose(spec_b, spec_c, atol=1e-08)
515
516 def test_psd_window_hanning(self):
517 if self.NFFT_density is None:

Callers

nothing calls this directly

Calls 1

psdMethod · 0.80

Tested by

no test coverage detected