code: def test_psd_nan():
      """Test handling of NaN in psd_array_welch."""
      n_samples, n_fft, n_overlap = 2048, 1024, 512
      x = np.random.RandomState(0).randn(1, n_samples)
      psds, freqs = psd_array_welch(
          x[:, : n_fft + n_overlap],
          float(n_fft),
          n_fft=n_fft,
          n_overlap=n_overlap,
      )
      x[
          :, n_fft + n_overlap :
      ] = np.nan  # what Raw.get_data() will give us
      psds_2, freqs_2 = psd_array_welch(
          x, float(n_fft), n_fft=n_fft, n_overlap=n_overlap
      )
      assert_allclose(freqs, freqs_2)
      assert_allclose(psds, psds_2)
      # 1-d
      psds_2, freqs_2 = psd_array_welch(
          x[0], float(n_fft), n_fft=n_fft, n_overlap=n_overlap
      )
      assert_allclose(freqs, freqs_2)
      assert_allclose(psds[0], psds_2)
      # defaults
      with catch_logging() as log:
          psd_array_welch(x, float(n_fft), verbose="debug")
      log = log.getvalue()
      assert "using 256-point FFT on 256 samples with 0 overlap" in log
      assert "hamming window" in log
  
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 1 for calling a global function with example usage: test_psd_nan() without return types