code: def test_ica_noop(n_components, n_pca_components, tmp_path):
      """Test that our ICA is stable even with a bad max_pca_components."""
      data = np.random.RandomState(0).randn(10, 1000)
      info = create_info(10, 1000.0, "eeg")
      raw = RawArray(data, info)
      raw.set_eeg_reference()
      with raw.info._unlock():
          raw.info["highpass"] = 1.0  # fake high-pass filtering
      assert np.linalg.matrix_rank(raw.get_data()) == 9
      kwargs = dict(n_components=n_components, verbose=True)
      if (
          isinstance(n_components, int)
          and isinstance(n_pca_components, int)
          and n_components > n_pca_components
      ):
          return
      ica = ICA(**kwargs)
      ica.n_pca_components = n_pca_components  # backward compat
      if n_components == 10 and n_pca_components == 0.9999:
          with pytest.raises(RuntimeError, match=".*requires.*PCA.*"):
              ica.fit(raw)
          return
      if n_components == 10 and n_pca_components == 10:
          ctx = pytest.warns(
              RuntimeWarning, match=".*unstable.*integer <= 9"
          )
          bad = True  # pinv will fail
      elif n_components == 0.9999 and n_pca_components == 8:
          ctx = pytest.raises(
              RuntimeError, match="requires 9 PCA values.*but"
          )
          bad = "exit"
      else:
          bad = False  # pinv will not fail
          ctx = nullcontext()
      with ctx:
          ica.fit(raw)
      assert ica._max_pca_components is None
      if bad == "exit":
          return
      raw_new = ica.apply(raw.copy())
      # 8 components is not a no-op; "bad" means our pinv has failed
      if n_pca_components == 8 or bad:
          assert ica.n_pca_components == n_pca_components
          assert not np.allclose(
              raw.get_data(), raw_new.get_data(), atol=0
          )
          return
      assert_allclose(
          raw.get_data(), raw_new.get_data(), err_msg="Id failure"
      )
      _assert_ica_attributes(ica, data)
      # and with I/O
      fname = tmp_path / "temp-ica.fif"
      ica.save(fname)
      ica_new = read_ica(fname)
      raw_new = ica_new.apply(raw.copy())
      assert_allclose(
          raw.get_data(), raw_new.get_data(), err_msg="I/O failure"
      )
      _assert_ica_attributes(ica_new)
      assert ica.reject_ == ica_new.reject_
  
imports: import os
  import shutil
  from contextlib import nullcontext
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg, stats
  from scipy.io import loadmat, savemat
  from mne import Annotations, Epochs, EpochsArray, EvokedArray, Info, create_info, make_ad_hoc_cov, pick_channels_regexp, pick_types, read_events
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT, get_channel_type_constants
  from mne.cov import read_cov
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.io import RawArray, read_raw_ctf, read_raw_eeglab, read_raw_fif
  from mne.io.eeglab.eeglab import _check_load_mat
  from mne.preprocessing import ICA
  from mne.preprocessing import ica_find_ecg_events, ica_find_eog_events, read_ica
  from mne.preprocessing.ica import _ica_explained_variance, _sort_components, corrmap, get_score_funcs, read_ica_eeglab
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings, catch_logging, check_version
label_desc: Use image node_id 6 for calling a global function with example usage: test_ica_noop(n_components, n_pca_components, tmp_path) without return types