code: def test_compute_proj_raw(tmp_path):
      """Test SSP computation on raw."""
      # Test that the raw projectors work
      raw_time = 2.5  # Do shorter amount for speed
      raw = read_raw_fif(raw_fname).crop(0, raw_time)
      raw.load_data()
      for ii in (0.25, 0.5, 1, 2):
          with pytest.warns(RuntimeWarning, match="Too few samples"):
              projs = compute_proj_raw(
                  raw,
                  duration=ii - 0.1,
                  stop=raw_time,
                  n_grad=1,
                  n_mag=1,
                  n_eeg=0,
              )
  
          # test that you can compute the projection matrix
          projs = activate_proj(projs)
          proj, nproj, U = make_projector(projs, raw.ch_names, bads=[])
  
          assert nproj == 2
          assert U.shape[1] == 2
  
          # test that you can save them
          with raw.info._unlock():
              raw.info["projs"] += projs
          raw.save(tmp_path / f"foo_{ii}_raw.fif", overwrite=True)
  
      # Test that purely continuous (no duration) raw projection works
      with pytest.warns(RuntimeWarning, match="Too few samples"):
          projs = compute_proj_raw(
              raw,
              duration=None,
              stop=raw_time,
              n_grad=1,
              n_mag=1,
              n_eeg=0,
          )
  
      # test that you can compute the projection matrix
      projs = activate_proj(projs)
      proj, nproj, U = make_projector(projs, raw.ch_names, bads=[])
  
      assert nproj == 2
      assert U.shape[1] == 2
  
      # test that you can save them
      with raw.info._unlock():
          raw.info["projs"] += projs
      raw.save(tmp_path / "foo_rawproj_continuous_raw.fif")
  
      # test resampled-data projector, upsampling instead of downsampling
      # here to save an extra filtering (raw would have to be LP'ed to be equiv)
      raw_resamp = cp.deepcopy(raw)
      raw_resamp.resample(raw.info["sfreq"] * 2, n_jobs=2, npad="auto")
      projs = compute_proj_raw(
          raw_resamp,
          duration=None,
          stop=raw_time,
          n_grad=1,
          n_mag=1,
          n_eeg=0,
      )
      projs = activate_proj(projs)
      proj_new, _, _ = make_projector(projs, raw.ch_names, bads=[])
      assert_array_almost_equal(proj_new, proj, 4)
  
      # test with bads
      raw.load_bad_channels(bads_fname)  # adds 2 bad mag channels
      with pytest.warns(RuntimeWarning, match="Too few samples"):
          projs = compute_proj_raw(raw, n_grad=0, n_mag=0, n_eeg=1)
      assert len(projs) == 1
  
      # test that bad channels can be excluded, and empty support
      for projs_ in (projs, []):
          proj, nproj, U = make_projector(
              projs_, raw.ch_names, bads=raw.ch_names
          )
          assert_array_almost_equal(proj, np.eye(len(raw.ch_names)))
          assert nproj == 0  # all channels excluded
          assert U.shape == (len(raw.ch_names), nproj)
  
imports: import copy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_equal
  from scipy import linalg
  from mne import Epochs, compute_proj_epochs, compute_proj_evoked, compute_proj_raw, compute_raw_covariance, convert_forward_solution, create_info, pick_types, read_events, read_forward_solution, read_source_estimate, sensitivity_map
  from mne._fiff.proj import _EEG_AVREF_PICK_DICT, _needs_eeg_average_ref_proj, activate_proj, make_projector, setup_proj
  from mne.cov import compute_whitener, regularize
  from mne.datasets import testing
  from mne.io import RawArray, read_raw_fif
  from mne.preprocessing import maxwell_filter
  from mne.proj import _has_eeg_average_ref_proj, make_eeg_average_ref_proj, read_proj, write_proj
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings
label_desc: Use image node_id 5 for calling a global function with example usage: test_compute_proj_raw(tmp_path) without return types