code: def test_stockwell_api():
      """Test stockwell functions."""
      raw = read_raw_fif(raw_fname)
      event_id, tmin, tmax = 1, -0.2, 0.5
      event_name = base_dir / "test-eve.fif"
      events = read_events(event_name)
      epochs = Epochs(
          raw,
          events,  # XXX pick 2 has epochs of zeros.
          event_id,
          tmin,
          tmax,
          picks=[0, 1, 3],
      )
      for fmin, fmax in [(None, 50), (5, 50), (5, None)]:
          power, itc = tfr_stockwell(
              epochs, fmin=fmin, fmax=fmax, return_itc=True
          )
          if fmax is not None:
              assert power.freqs.max() <= fmax
          power_evoked = tfr_stockwell(
              epochs.average(), fmin=fmin, fmax=fmax, return_itc=False
          )
          # for multitaper these don't necessarily match, but they seem to
          # for stockwell... if this fails, this maybe could be changed
          # just to check the shape
          assert_array_almost_equal(power_evoked.data, power.data)
      assert isinstance(power, AverageTFR)
      assert isinstance(itc, AverageTFR)
      assert_equal(power.data.shape, itc.data.shape)
      assert itc.data.min() >= 0.0
      assert itc.data.max() <= 1.0
      assert np.log(power.data.max()) * 20 <= 0.0
      assert np.log(power.data.max()) * 20 <= 0.0
      with pytest.raises(TypeError, match="ndarray"):
          tfr_array_stockwell("foo", 1000.0)
      data = np.random.RandomState(0).randn(1, 1024)
      with pytest.raises(ValueError, match="3D with shape"):
          tfr_array_stockwell(data, 1000.0)
      data = data[np.newaxis]
      power, itc, freqs = tfr_array_stockwell(
          data, 1000.0, return_itc=True
      )
      assert_allclose(itc, np.ones_like(itc))
      assert power.shape == (1, len(freqs), data.shape[-1])
      assert_array_less(0, power)
  
file_path: mne-python/mne/time_frequency/tests/test_stockwell.py
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_less, assert_equal
  from scipy import fftpack
  from mne import Epochs, make_fixed_length_events, read_events
  from mne.io import read_raw_fif
  from mne.time_frequency import AverageTFR, tfr_array_stockwell
  from mne.time_frequency._stockwell import _check_input_st, _precompute_st_windows, _st, _st_power_itc, tfr_stockwell
  from mne.utils import _record_warnings
label_desc: Use image node_id 5 for calling a global function with example usage: test_stockwell_api() without return types