code: def test_ornt2axcodes():
      # Recoding orientation to axis codes
      labels = (("left", "right"), ("back", "front"), ("down", "up"))
      assert ornt2axcodes([[0, 1], [1, 1], [2, 1]], labels) == (
          "right",
          "front",
          "up",
      )
      assert ornt2axcodes([[0, -1], [1, -1], [2, -1]], labels) == (
          "left",
          "back",
          "down",
      )
      assert ornt2axcodes([[2, -1], [1, -1], [0, -1]], labels) == (
          "down",
          "back",
          "left",
      )
      assert ornt2axcodes([[1, 1], [2, -1], [0, 1]], labels) == (
          "front",
          "down",
          "right",
      )
      # default is RAS output directions
      assert ornt2axcodes([[0, 1], [1, 1], [2, 1]]) == ("R", "A", "S")
      # dropped axes produce None
      assert ornt2axcodes([[0, 1], [np.nan, np.nan], [2, 1]]) == (
          "R",
          None,
          "S",
      )
      # Non integer axes raises error
      with pytest.raises(ValueError):
          ornt2axcodes([[0.1, 1]])
      # As do directions not in range
      with pytest.raises(ValueError):
          ornt2axcodes([[0, 0]])
  
      for axcodes, ornt in zip(ALL_AXCODES, ALL_ORNTS):
          assert ornt2axcodes(ornt) == axcodes
  
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 5 for calling a global function with example usage: test_ornt2axcodes() without return types