code: def test_series():
      """
      Test the introspection and creation of CIFTI-2 SeriesAxis axes
      """
      sr = list(get_series())
      assert sr[0].unit == "SECOND"
      assert sr[1].unit == "SECOND"
      assert sr[2].unit == "SECOND"
      assert sr[3].unit == "HERTZ"
      sr[0].unit = "hertz"
      assert sr[0].unit == "HERTZ"
      with pytest.raises(ValueError):
          sr[0].unit = "non_existent"
  
      sr = list(get_series())
      assert (sr[0].time == np.arange(4) * 10 + 3).all()
      assert (sr[1].time == np.arange(3) * 10 + 8).all()
      assert (sr[2].time == np.arange(4) * 2 + 3).all()
      assert ((sr[0] + sr[1]).time == np.arange(7) * 10 + 3).all()
      assert ((sr[1] + sr[0]).time == np.arange(7) * 10 + 8).all()
      assert (
          (sr[1] + sr[0] + sr[0]).time == np.arange(11) * 10 + 8
      ).all()
      assert sr[1][2] == 28
      assert sr[1][-2] == sr[1].time[-2]
  
      with pytest.raises(ValueError):
          sr[0] + sr[2]
      with pytest.raises(ValueError):
          sr[2] + sr[1]
      with pytest.raises(ValueError):
          sr[0] + sr[3]
      with pytest.raises(ValueError):
          sr[3] + sr[1]
      with pytest.raises(ValueError):
          sr[3] + sr[2]
  
      # test slicing
      assert (sr[0][1:3].time == sr[0].time[1:3]).all()
      assert (sr[0][1:].time == sr[0].time[1:]).all()
      assert (sr[0][:-2].time == sr[0].time[:-2]).all()
      assert (sr[0][1:-1].time == sr[0].time[1:-1]).all()
      assert (sr[0][1:-1:2].time == sr[0].time[1:-1:2]).all()
      assert (sr[0][::2].time == sr[0].time[::2]).all()
      assert (sr[0][:10:2].time == sr[0].time[::2]).all()
      assert (sr[0][10:].time == sr[0].time[10:]).all()
      assert (sr[0][10:12].time == sr[0].time[10:12]).all()
      assert (sr[0][10::-1].time == sr[0].time[10::-1]).all()
      assert (sr[0][3:1:-1].time == sr[0].time[3:1:-1]).all()
      assert (sr[0][1:3:-1].time == sr[0].time[1:3:-1]).all()
  
      with pytest.raises(IndexError):
          assert sr[0][[0, 1]]
      with pytest.raises(IndexError):
          assert sr[0][20]
      with pytest.raises(IndexError):
          assert sr[0][-20]
  
      # test_equalities
      sr = next(get_series())
      with pytest.raises(Exception):
          sr + get_scalar()
      assert sr != sr[:2]
      assert sr == sr[:]
  
      for key, value in (
          ("start", 20),
          ("step", 7),
          ("size", 14),
          ("unit", "HERTZ"),
      ):
          sr_other = deepcopy(sr)
          assert sr == sr_other
          setattr(sr_other, key, value)
          assert sr != sr_other
  
file_path: nibabel/nibabel/cifti2/tests/test_axes.py
imports: from copy import deepcopy
  import numpy
  import pytest
  import nibabel.cifti2.cifti2_axes
  from .test_cifti2io_axes import check_rewrite
label_desc: Use image node_id 11 for calling a global function with example usage: test_series() without return types