code: def test_notch_filters(method, filter_length, line_freq, tol):
      """Test notch filters."""
      # let's use an ugly, prime sfreq for fun
      rng = np.random.RandomState(0)
      sfreq = 487
      sig_len_secs = 21
      t = np.arange(0, int(round(sig_len_secs * sfreq))) / sfreq
  
      # make a "signal"
      a = rng.randn(int(sig_len_secs * sfreq))
      orig_power = np.sqrt(np.mean(a**2))
      # make line noise
      a += np.sum(
          [np.sin(2 * np.pi * f * t) for f in line_freqs], axis=0
      )
  
      # only allow None line_freqs with 'spectrum_fit' mode
      for kind in ("fir", "iir"):
          with pytest.raises(
              ValueError, match="freqs=None can only be used wi"
          ):
              notch_filter(a, sfreq, None, kind)
      with catch_logging() as log_file:
          b = notch_filter(
              a,
              sfreq,
              line_freq,
              filter_length,
              method=method,
              verbose=True,
          )
      if line_freq is None:
          out = [
              line.strip().split(":")[0]
              for line in log_file.getvalue().split("\n")
              if line.startswith(" ")
          ]
          assert (
              len(out) == 4
          ), "Detected frequencies not logged properly"
          out = np.array(out, float)
          assert_array_almost_equal(out, line_freqs)
      new_power = np.sqrt(sum_squared(b) / b.size)
      assert_almost_equal(new_power, orig_power, tol)
  
imports: import numpy
  import pytest
  from numpy.fft import fft, fftfreq
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, assert_array_equal, assert_array_less
  from scipy.signal import butter, freqz, sosfreqz
  from scipy.signal import resample
  from mne import Epochs, create_info
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT
  from mne.filter import _length_factors, _overlap_add_filter, _resample_stim_channels, _smart_pad, construct_iir_filter, create_filter, design_mne_c_filter, detrend, estimate_ringing_samples, filter_data, notch_filter, resample
  from mne.io import RawArray, read_raw_fif
  from mne.utils import catch_logging, requires_mne, run_subprocess, sum_squared
label_desc: Use image node_id 7 for calling a global function with example usage: test_notch_filters(method, filter_length, line_freq, tol) without return types