code: def test_annotations_crop():
      """Test basic functionality of annotation crop."""
      onset = np.arange(1, 10)
      duration = np.full_like(onset, 10)
      description = ["yy"] * onset.shape[0]
  
      a = Annotations(
          onset=onset,
          duration=duration,
          description=description,
          orig_time=0,
      )
  
      # cropping window larger than annotations --> do not modify
      a_ = a.copy().crop(tmin=-10, tmax=42)
      assert_array_equal(a_.onset, a.onset)
      assert_array_equal(a_.duration, a.duration)
  
      # cropping with left shifted window
      with _record_warnings() as w:
          a_ = a.copy().crop(tmin=0, tmax=4.2)
      assert_array_equal(a_.onset, [1.0, 2.0, 3.0, 4.0])
      assert_allclose(a_.duration, [3.2, 2.2, 1.2, 0.2])
      assert len(w) == 0
  
      # cropping with right shifted window
      with _record_warnings() as w:
          a_ = a.copy().crop(tmin=17.8, tmax=22)
      assert_array_equal(a_.onset, [17.8, 17.8])
      assert_allclose(a_.duration, [0.2, 1.2])
      assert len(w) == 0
  
      # cropping with centered small window
      a_ = a.copy().crop(tmin=11, tmax=12)
      assert_array_equal(a_.onset, [11, 11, 11, 11, 11, 11, 11, 11, 11])
      assert_array_equal(a_.duration, [0, 1, 1, 1, 1, 1, 1, 1, 1])
  
      # cropping with out-of-bounds window
      with _record_warnings() as w:
          a_ = a.copy().crop(tmin=42, tmax=100)
      assert_array_equal(a_.onset, [])
      assert_array_equal(a_.duration, [])
      assert len(w) == 0
  
      # test error raising
      with pytest.raises(
          ValueError, match="tmax should be greater than.*tmin"
      ):
          a.copy().crop(tmin=42, tmax=0)
  
      # test warnings
      with pytest.warns(
          RuntimeWarning, match="Omitted .* were outside"
      ):
          a.copy().crop(tmin=42, tmax=100, emit_warning=True)
      with pytest.warns(
          RuntimeWarning, match="Limited .* expanding outside"
      ):
          a.copy().crop(tmin=0, tmax=12, emit_warning=True)
  
imports: import sys
  from collections import OrderedDict
  from datetime import datetime, timedelta, timezone
  from itertools import repeat
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from pytest import approx
  import mne
  from mne import Annotations, Epochs, annotations_from_events, count_annotations, create_info, events_from_annotations, read_annotations
  from mne.annotations import _handle_meas_date, _read_annotations_txt_parse_header, _sync_onset
  from mne.datasets import testing
  from mne.io import RawArray, concatenate_raws, read_raw_fif
  from mne.utils import _dt_to_stamp, _raw_annot, _record_warnings, _stamp_to_dt, assert_and_remove_boundary_annot, catch_logging, check_version
label_desc: Use image node_id 16 for calling a global function with example usage: test_annotations_crop() without return types