code: def test_apply():
      # most tests are in ``same_transform`` above, via the
      # test_io_orientations
      a = np.arange(24).reshape((2, 3, 4))
      # Test 4D with an example orientation
      ornt = OUT_ORNTS[-1]
      t_arr = apply_orientation(a[:, :, :, None], ornt)
      assert t_arr.ndim == 4
      # Orientation errors
      with pytest.raises(OrientationError):
          apply_orientation(a[:, :, 1], ornt)
      with pytest.raises(OrientationError):
          apply_orientation(a, [[0, 1], [np.nan, np.nan], [2, 1]])
      shape = np.array(a.shape)
      for ornt in ALL_ORNTS:
          t_arr = apply_orientation(a, ornt)
          assert_array_equal(
              a.shape, np.array(t_arr.shape)[np.array(ornt)[:, 0]]
          )
  
file_path: nibabel/nibabel/tests/test_orientations.py
imports: import warnings
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..affines import from_matvec, to_matvec
  from ..orientations import OrientationError, aff2axcodes, apply_orientation, axcodes2ornt, flip_axis, inv_ornt_aff, io_orientation, ornt2axcodes, ornt_transform
  from ..testing import expires
label_desc: Use image node_id 2 for calling a global function with example usage: test_apply() without return types