code: def test_check_consistency():
      """Test consistency check of Info objects."""
      info = create_info(ch_names=["a", "b", "c"], sfreq=1000.0)
  
      # This should pass
      info._check_consistency()
  
      # Info without any channels
      info_empty = create_info(ch_names=[], sfreq=1000.0)
      info_empty._check_consistency()
  
      # Bad channels that are not in the info object
      info2 = info.copy()
      with pytest.raises(ValueError, match="do not exist"):
          info2["bads"] = ["b", "foo", "bar"]
  
      # Bad data types
      info2 = info.copy()
      with info2._unlock():
          info2["sfreq"] = "foo"
      pytest.raises(ValueError, info2._check_consistency)
  
      info2 = info.copy()
      with info2._unlock():
          info2["highpass"] = "foo"
      pytest.raises(ValueError, info2._check_consistency)
  
      info2 = info.copy()
      with info2._unlock():
          info2["lowpass"] = "foo"
      pytest.raises(ValueError, info2._check_consistency)
  
      # Silent type conversion to float
      info2 = info.copy()
      with info2._unlock(check_after=True):
          info2["sfreq"] = 1
          info2["highpass"] = 2
          info2["lowpass"] = 2
      assert isinstance(info2["sfreq"], float)
      assert isinstance(info2["highpass"], float)
      assert isinstance(info2["lowpass"], float)
  
      # Duplicate channel names
      info2 = info.copy()
      with info2._unlock():
          info2["chs"][2]["ch_name"] = "b"
      pytest.raises(RuntimeError, info2._check_consistency)
  
      # Duplicates appended with running numbers
      with pytest.warns(RuntimeWarning, match="Channel names are not"):
          info3 = create_info(
              ch_names=["a", "b", "b", "c", "b"], sfreq=1000.0
          )
      assert_array_equal(
          info3["ch_names"], ["a", "b-0", "b-1", "c", "b-2"]
      )
  
      # a few bad ones
      idx = 0
      ch = info["chs"][idx]
      for key, bad, match in (
          ("ch_name", 1.0, "not a string"),
          ("loc", np.zeros(15), "12 elements"),
          ("cal", np.ones(1), "float or int"),
      ):
          info._check_consistency()  # okay
          old = ch[key]
          ch[key] = bad
          if key == "ch_name":
              info["ch_names"][idx] = bad
          with pytest.raises(TypeError, match=match):
              info._check_consistency()
          ch[key] = old
          if key == "ch_name":
              info["ch_names"][idx] = old
  
      # bad channel entries
      info2 = info.copy()
      info2["chs"][0]["foo"] = "bar"
      with pytest.raises(KeyError, match="key errantly present"):
          info2._check_consistency()
      info2 = info.copy()
      del info2["chs"][0]["loc"]
      with pytest.raises(KeyError, match="key missing"):
          info2._check_consistency()
  
imports: import pickle
  import string
  from datetime import date, datetime, timedelta, timezone
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from mne import Annotations, Epochs, compute_covariance, make_forward_solution, make_sphere_model, pick_info, pick_types, read_cov, read_epochs, read_events, read_evokeds, read_forward_solution, setup_volume_source_space, write_cov, write_forward_solution
  from mne._fiff import meas_info
  from mne._fiff._digitization import DigPoint, _make_dig_points
  from mne._fiff.constants import FIFF
  from mne._fiff.meas_info import RAW_INFO_FIELDS, Info, MNEBadsList, _add_timedelta_to_stamp, _bad_chans_comp, _dt_to_stamp, _force_update_info, _get_valid_units, _merge_info, _read_extended_ch_info, _stamp_to_dt, anonymize_info, create_info, read_fiducials, read_info, write_fiducials, write_info
  from mne._fiff.proj import Projection
  from mne._fiff.tag import _coil_trans_to_loc, _loc_to_coil_trans
  from mne._fiff.write import DATE_NONE, _generate_meas_id
  from mne.channels import equalize_channels, make_standard_montage, read_polhemus_fastscan
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.io import BaseRaw, RawArray, read_raw_ctf, read_raw_fif
  from mne.minimum_norm import apply_inverse, make_inverse_operator, read_inverse_operator, write_inverse_operator
  from mne.transforms import Transform
  from mne.utils import _empty_hash, _record_warnings, assert_object_equal, catch_logging
label_desc: Use image node_id 15 for calling a global function with example usage: test_check_consistency() without return types