code: def test_io_cov(tmp_path):
      """Test IO for noise covariance matrices."""
      cov = read_cov(cov_fname)
      cov["method"] = "empirical"
      cov["loglik"] = -np.inf
      cov.save(tmp_path / "test-cov.fif")
      cov2 = read_cov(tmp_path / "test-cov.fif")
      assert_array_almost_equal(cov.data, cov2.data)
      assert_equal(cov["method"], cov2["method"])
      assert_equal(cov["loglik"], cov2["loglik"])
      assert "Covariance" in repr(cov)
      assert "range :" in repr(cov)
      assert "\n" not in repr(cov)
  
      cov2 = read_cov(cov_gz_fname)
      assert_array_almost_equal(cov.data, cov2.data)
      cov2.save(tmp_path / "test-cov.fif.gz")
      cov2 = read_cov(tmp_path / "test-cov.fif.gz")
      assert_array_almost_equal(cov.data, cov2.data)
  
      cov["bads"] = ["EEG 039"]
      cov_sel = pick_channels_cov(cov, exclude=cov["bads"])
      assert cov_sel["dim"] == (len(cov["data"]) - len(cov["bads"]))
      assert cov_sel["data"].shape == (cov_sel["dim"], cov_sel["dim"])
      cov_sel.save(tmp_path / "test-cov.fif", overwrite=True)
  
      cov2 = read_cov(cov_gz_fname)
      assert_array_almost_equal(cov.data, cov2.data)
      cov2.save(tmp_path / "test-cov.fif.gz", overwrite=True)
      cov2 = read_cov(tmp_path / "test-cov.fif.gz")
      assert_array_almost_equal(cov.data, cov2.data)
  
      # test warnings on bad filenames
      cov_badname = tmp_path / "test-bad-name.fif.gz"
      with pytest.warns(RuntimeWarning, match="-cov.fif"):
          write_cov(cov_badname, cov)
      with pytest.warns(RuntimeWarning, match="-cov.fif"):
          read_cov(cov_badname)
  
imports: import itertools
  import sys
  from inspect import signature
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import Epochs, compute_covariance, compute_proj_raw, compute_rank, compute_raw_covariance, create_info, find_events, make_ad_hoc_cov, make_fixed_length_events, merge_events, pick_channels_cov, pick_info, pick_types, read_cov, read_evokeds, write_cov
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT
  from mne.channels import equalize_channels
  from mne.cov import _auto_low_rank_model, _regularized_covariance, compute_whitener, prepare_noise_cov, regularize, whiten_evoked
  from mne.datasets import testing
  from mne.fixes import _safe_svd
  from mne.io import RawArray, read_info, read_raw_ctf, read_raw_fif
  from mne.preprocessing import maxwell_filter
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings, assert_snr, catch_logging
label_desc: Use image node_id 6 for calling a global function with example usage: test_io_cov(tmp_path) without return types