code: def test_ref_degenerate():
      """Test reference channel handling and degenerate conditions."""
      info = read_info(ctf_fname)
      # exclude ref by default
      projs = compute_proj_hfc(info)
      meg_names = [
          info["ch_names"][pick]
          for pick in pick_types(
              info, meg=True, ref_meg=False, exclude=[]
          )
      ]
      assert len(projs) == 3
      assert projs[0]["desc"] == "HFC: l=1 m=-1"
      assert projs[1]["desc"] == "HFC: l=1 m=0"
      assert projs[2]["desc"] == "HFC: l=1 m=1"
      assert projs[0]["data"]["col_names"] == meg_names
      meg_ref_names = [
          info["ch_names"][pick]
          for pick in pick_types(
              info, meg=True, ref_meg=True, exclude=[]
          )
      ]
      projs = compute_proj_hfc(info, picks=("meg", "ref_meg"))
      assert projs[0]["data"]["col_names"] == meg_ref_names
  
      # Degenerate
      info = read_info(fif_fname)
      compute_proj_hfc(info)  # smoke test
      with pytest.raises(
          ValueError, match="Only.*could be interpreted as MEG"
      ):
          compute_proj_hfc(info, picks=[0, 330])  # one MEG, one EEG
      info["chs"][0]["loc"][:] = np.nan  # first MEG proj
      with pytest.raises(ValueError, match="non-finite projectors"):
          compute_proj_hfc(info)
      info_eeg = pick_info(info, pick_types(info, meg=False, eeg=True))
      with pytest.raises(
          ValueError, match=r"picks \(\'meg\'\) could not be"
      ):
          compute_proj_hfc(info_eeg)
  
file_path: mne-python/mne/preprocessing/tests/test_hfc.py
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose
  from scipy.io import loadmat
  from mne._fiff.pick import pick_channels, pick_info, pick_types
  from mne.datasets import testing
  from mne.io import read_info, read_raw_fil
  from mne.preprocessing.hfc import compute_proj_hfc
label_desc: Use image node_id 5 for calling a global function with example usage: test_ref_degenerate() without return types