code: def test_proj_raw_duration(duration, sfreq):
      """Test equivalence of `duration` options."""
      n_ch, n_dim = 30, 3
      rng = np.random.RandomState(0)
      signals = rng.randn(n_dim, 10000)
      mixing = rng.randn(n_ch, n_dim) + [0, 1, 2]
      data = np.dot(mixing, signals)
      raw = RawArray(data, create_info(n_ch, sfreq, "eeg"))
      raw.set_eeg_reference(projection=True)
      n_eff = int(round(raw.info["sfreq"] * duration))
      # crop to an even "duration" number of epochs
      stop = ((len(raw.times) // n_eff) * n_eff - 1) / raw.info["sfreq"]
      raw.crop(0, stop)
      proj_def = compute_proj_raw(raw, n_eeg=n_dim)
      proj_dur = compute_proj_raw(raw, duration=duration, n_eeg=n_dim)
      proj_none = compute_proj_raw(raw, duration=None, n_eeg=n_dim)
      assert len(proj_dur) == len(proj_none) == len(proj_def) == n_dim
      # proj_def is not in here because it does not necessarily evenly divide
      # the signal length:
      for pu, pn in zip(proj_dur, proj_none):
          assert_allclose(pu["data"]["data"], pn["data"]["data"])
      # but we can test it here since it should still be a small subspace angle:
      for proj in (proj_dur, proj_none, proj_def):
          computed = np.concatenate(
              [p["data"]["data"] for p in proj], 0
          )
          angle = np.rad2deg(
              linalg.subspace_angles(computed.T, mixing)[0]
          )
          assert angle < 1e-5
  
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 6 for calling a global function with example usage: test_proj_raw_duration(duration, sfreq) without return types