code: def test_time_as_index_and_crop():
      """Test time as index and cropping."""
      tmin, tmax = -0.1, 0.1
      evoked = read_evokeds(fname, condition=0).crop(tmin, tmax)
      delta = 1.0 / evoked.info["sfreq"]
      atol = 0.5 * delta
      assert_allclose(evoked.times[[0, -1]], [tmin, tmax], atol=atol)
      assert_array_equal(
          evoked.time_as_index([-0.1, 0.1], use_rounding=True),
          [0, len(evoked.times) - 1],
      )
      evoked.crop(evoked.tmin, evoked.tmax, include_tmax=False)
      n_times = len(evoked.times)
      with pytest.warns(RuntimeWarning, match="tmax is set to"):
          evoked.crop(tmin, tmax, include_tmax=False)
      assert len(evoked.times) == n_times
      assert_allclose(
          evoked.times[[0, -1]], [tmin, tmax - delta], atol=atol
      )
  
imports: import pickle
  from copy import deepcopy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import fftpack
  from mne import Epochs, EpochsArray, combine_evoked, create_info, equalize_channels, pick_types, read_events, read_evokeds, write_evokeds
  from mne._fiff.constants import FIFF
  from mne.evoked import Evoked, EvokedArray, _get_peak
  from mne.io import read_raw_fif
  from mne.utils import grand_average
label_desc: Use image node_id 23 for calling a global function with example usage: test_time_as_index_and_crop() without return types