code: def test_channel_name_limit(tmp_path, monkeypatch, fname):
      """Test that our remapping works properly."""
      #
      # raw
      #
      if fname.suffix == ".fif":
          raw = read_raw_fif(fname)
          raw.pick(raw.ch_names[:3])
          ref_names = []
          data_names = raw.ch_names
      else:
          assert fname.suffix == ".ds"
          raw = read_raw_ctf(fname)
          ref_names = [
              raw.ch_names[pick]
              for pick in pick_types(raw.info, meg=False, ref_meg=True)
          ]
          data_names = raw.ch_names[32:35]
      proj = dict(
          data=np.ones((1, len(data_names))),
          col_names=data_names[:2].copy(),
          row_names=None,
          nrow=1,
      )
      proj = Projection(
          data=proj,
          active=False,
          desc="test",
          kind=0,
          explained_var=0.0,
      )
      raw.add_proj(proj, remove_existing=True)
      raw.info.normalize_proj()
      raw.pick(data_names + ref_names).crop(0, 2)
      long_names = ["123456789abcdefg" + name for name in raw.ch_names]
      fname = tmp_path / "test-raw.fif"
      with catch_logging() as log:
          raw.save(fname)
      log = log.getvalue()
      assert "truncated" not in log
      rename = dict(zip(raw.ch_names, long_names))
      long_data_names = [rename[name] for name in data_names]
      long_proj_names = long_data_names[:2]
      raw.rename_channels(rename)
      for comp in raw.info["comps"]:
          for key in ("row_names", "col_names"):
              for name in comp["data"][key]:
                  assert name in raw.ch_names
      if raw.info["comps"]:
          assert raw.compensation_grade == 0
          raw.apply_gradient_compensation(3)
          assert raw.compensation_grade == 3
      assert len(raw.info["projs"]) == 1
      assert (
          raw.info["projs"][0]["data"]["col_names"] == long_proj_names
      )
      raw.info["bads"] = bads = long_data_names[2:3]
      good_long_data_names = [
          name for name in long_data_names if name not in bads
      ]
      with catch_logging() as log:
          raw.save(fname, overwrite=True, verbose=True)
      log = log.getvalue()
      assert "truncated to 15" in log
      for name in raw.ch_names:
          assert len(name) > 15
      # first read the full way
      with catch_logging() as log:
          raw_read = read_raw_fif(fname, verbose=True)
      log = log.getvalue()
      assert "Reading extended channel information" in log
      for ra in (raw, raw_read):
          assert ra.ch_names == long_names
      assert (
          raw_read.info["projs"][0]["data"]["col_names"]
          == long_proj_names
      )
      del raw_read
      # next read as if no longer names could be read
      monkeypatch.setattr(
          meas_info, "_read_extended_ch_info", lambda x, y, z: None
      )
      with catch_logging() as log:
          raw_read = read_raw_fif(fname, verbose=True)
      log = log.getvalue()
      assert "extended" not in log
      if raw.info["comps"]:
          assert raw_read.compensation_grade == 3
          raw_read.apply_gradient_compensation(0)
          assert raw_read.compensation_grade == 0
      monkeypatch.setattr(  # restore
          meas_info, "_read_extended_ch_info", _read_extended_ch_info
      )
      short_proj_names = [
          f"{name[:13 - bool(len(ref_names))]}-{ni}"
          for ni, name in enumerate(long_proj_names)
      ]
      assert (
          raw_read.info["projs"][0]["data"]["col_names"]
          == short_proj_names
      )
      #
      # epochs
      #
      epochs = Epochs(raw, make_fixed_length_events(raw))
      fname = tmp_path / "test-epo.fif"
      epochs.save(fname)
      epochs_read = read_epochs(fname)
      for ep in (epochs, epochs_read):
          assert ep.info["ch_names"] == long_names
          assert ep.ch_names == long_names
      del raw, epochs_read
      # cov
      epochs.info["bads"] = []
      cov = compute_covariance(epochs, verbose="error")
      fname = tmp_path / "test-cov.fif"
      write_cov(fname, cov)
      cov_read = read_cov(fname)
      for co in (cov, cov_read):
          assert co["names"] == long_data_names
          assert co["bads"] == []
      del cov_read
  
      #
      # evoked
      #
      evoked = epochs.average()
      evoked.info["bads"] = bads
      assert evoked.nave == 1
      fname = tmp_path / "test-ave.fif"
      evoked.save(fname)
      evoked_read = read_evokeds(fname)[0]
      for ev in (evoked, evoked_read):
          assert ev.ch_names == long_names
          assert ev.info["bads"] == bads
      del evoked_read, epochs
  
      #
      # forward
      #
      with _record_warnings():  # not enough points for CTF
          sphere = make_sphere_model("auto", "auto", evoked.info)
      src = setup_volume_source_space(
          pos=dict(rr=[[0, 0, 0.04]], nn=[[0, 1.0, 0.0]])
      )
      fwd = make_forward_solution(evoked.info, None, src, sphere)
      fname = tmp_path / "temp-fwd.fif"
      write_forward_solution(fname, fwd)
      fwd_read = read_forward_solution(fname)
      for fw in (fwd, fwd_read):
          assert fw["sol"]["row_names"] == long_data_names
          assert fw["info"]["ch_names"] == long_data_names
          assert fw["info"]["bads"] == bads
      del fwd_read
  
      #
      # inv
      #
      inv = make_inverse_operator(evoked.info, fwd, cov)
      fname = tmp_path / "test-inv.fif"
      write_inverse_operator(fname, inv)
      inv_read = read_inverse_operator(fname)
      for iv in (inv, inv_read):
          assert iv["info"]["ch_names"] == good_long_data_names
      apply_inverse(evoked, inv)
  
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 27 for calling a global function with example usage: test_channel_name_limit(tmp_path, monkeypatch, fname) without return types