code: def test_psd(psd_func, psd_kwargs):
      """Tests the welch and multitaper PSD."""
      data, sfreq, sinusoid_freqs = _make_psd_data()
      # prepare kwargs
      psd_kwargs.update(dict(fmin=2, fmax=70, verbose="debug"))
      # compute PSD and test basic conformity
      with catch_logging() as log:
          psds, freqs = psd_func(data, sfreq, **psd_kwargs)
      if psd_func is psd_array_welch:
          log = log.getvalue()
          n_fft = psd_kwargs["n_fft"]
          assert (
              f"{n_fft}-point FFT on {n_fft} samples with 0 overl"
              in log
          )
          assert "hann window" in log
      assert psds.shape == (data.shape[0], len(freqs))
      assert np.sum(freqs < 0) == 0
      assert np.sum(psds < 0) == 0
      # Is power found where it should be?
      ixs_max = np.argmax(psds, axis=1)
      for ixmax, ifreq in zip(ixs_max, sinusoid_freqs):
          # Find nearest frequency to the "true" freq
          ixtrue = np.argmin(np.abs(ifreq - freqs))
          assert np.abs(ixmax - ixtrue) < 2
  
file_path: mne-python/mne/time_frequency/tests/test_psd.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal
  from scipy.signal import welch
  from mne.time_frequency import psd_array_multitaper, psd_array_welch
  from mne.time_frequency.multitaper import _psd_from_mt
  from mne.time_frequency.psd import _median_biases
  from mne.utils import catch_logging
label_desc: Use image node_id 3 for calling a global function with example usage: test_psd(psd_func, psd_kwargs) without return types