code: def test_axmap():
      # Test mapping between axes
      cmap = AffineTransform("ijk", "xyz", np.eye(4))
      assert axmap(cmap) == {0: 0, 1: 1, 2: 2, "i": 0, "j": 1, "k": 2}
      assert axmap(cmap, "out2in") == {
          0: 0,
          1: 1,
          2: 2,
          "x": 0,
          "y": 1,
          "z": 2,
      }
      assert axmap(cmap, "both") == (
          {0: 0, 1: 1, 2: 2, "i": 0, "j": 1, "k": 2},
          {0: 0, 1: 1, 2: 2, "x": 0, "y": 1, "z": 2},
      )
      cmap = AffineTransform(
          "ijk",
          "xyz",
          [[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1]],
      )
      assert axmap(cmap) == {0: 2, 1: 0, 2: 1, "i": 2, "j": 0, "k": 1}
      assert axmap(cmap, "out2in") == {
          2: 0,
          0: 1,
          1: 2,
          "z": 0,
          "x": 1,
          "y": 2,
      }
      # Test in presence of nasty zero
      cmap = AffineTransform("ijk", "xyz", np.diag([2, 3, 0, 1]))
      # Default is to fix zero
      assert axmap(cmap) == {0: 0, 1: 1, 2: 2, "i": 0, "j": 1, "k": 2}
      assert axmap(cmap, fix0=True) == {
          0: 0,
          1: 1,
          2: 2,
          "i": 0,
          "j": 1,
          "k": 2,
      }
      assert axmap(cmap, "out2in") == {
          0: 0,
          1: 1,
          2: 2,
          "x": 0,
          "y": 1,
          "z": 2,
      }
      # If turned off, we can't find the axis anymore
      assert axmap(cmap, fix0=False) == {
          0: 0,
          1: 1,
          2: None,
          "i": 0,
          "j": 1,
          "k": None,
      }
      assert axmap(cmap, "out2in", fix0=False) == {
          0: 0,
          1: 1,
          2: None,
          "x": 0,
          "y": 1,
          "z": None,
      }
      # Need in2out or out2in as action strings
      pytest.raises(ValueError, axmap, cmap, "do what exactly?")
      # Non-square
      cmap = AffineTransform(
          "ij", "xyz", [[0, 1, 0], [0, 0, 0], [1, 0, 0], [0, 0, 1]]
      )
      assert axmap(cmap) == {0: 2, 1: 0, "i": 2, "j": 0}
      assert axmap(cmap, "out2in") == {
          0: 1,
          1: None,
          2: 0,
          "x": 1,
          "y": None,
          "z": 0,
      }
      cmap = AffineTransform(
          "ijk", "xy", [[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
      )
      assert axmap(cmap) == {
          0: None,
          1: 0,
          2: 1,
          "i": None,
          "j": 0,
          "k": 1,
      }
      assert axmap(cmap, "out2in") == {0: 1, 1: 2, "x": 1, "y": 2}
      # What happens if there are ties?
      cmap = AffineTransform(
          "ijk",
          "xyz",
          [[0, 1, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1]],
      )
      assert axmap(cmap) == {
          0: 2,
          1: 0,
          2: None,
          "i": 2,
          "j": 0,
          "k": None,
      }
      assert axmap(cmap, "out2in") == {
          0: 1,
          1: None,
          2: 0,
          "x": 1,
          "y": None,
          "z": 0,
      }
  
imports: from copy import copy
  from types import SimpleNamespace
  import numpy
  from ..coordinate_map import AffineTransform, AxisError, CoordinateMap, CoordMapMaker, CoordMapMakerError, _as_coordinate_map, _fix0, append_io_dim, axmap, compose, drop_io_dim, equivalent, input_axis_index, io_axis_indices, orth_axes, product, shifted_domain_origin, shifted_range_origin
  from ..coordinate_system import CoordinateSystem, CoordinateSystemError, CoordSysMaker
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
label_desc: Use image node_id 35 for calling a global function with example usage: test_axmap() without return types