code: def test_drop_io_dim():
      # test ordinary case of 4d to 3d
      cm4d = AffineTransform.from_params(
          "ijkl", "xyzt", np.diag([1, 2, 3, 4, 1])
      )
      cm3d = drop_io_dim(cm4d, "t")
      assert_array_equal(cm3d.affine, np.diag([1, 2, 3, 1]))
      cm3d = drop_io_dim(cm4d, "l")
      assert_array_equal(cm3d.affine, np.diag([1, 2, 3, 1]))
      cm3d = drop_io_dim(cm4d, 3)
      assert_array_equal(cm3d.affine, np.diag([1, 2, 3, 1]))
      cm3d = drop_io_dim(cm4d, -1)
      assert_array_equal(cm3d.affine, np.diag([1, 2, 3, 1]))
      # 3d to 2d
      cm3d = AffineTransform.from_params(
          "ijk", "xyz", np.diag([1, 2, 3, 1])
      )
      cm2d = drop_io_dim(cm3d, "z")
      assert_array_equal(cm2d.affine, np.diag([1, 2, 1]))
      # test zero scaling for dropped dimension
      cm3d = AffineTransform.from_params(
          "ijk", "xyz", np.diag([1, 2, 0, 1])
      )
      cm2d = drop_io_dim(cm3d, "z")
      assert_array_equal(cm2d.affine, np.diag([1, 2, 1]))
      # test not diagonal but orthogonal
      aff = np.array(
          [[1, 0, 0, 0], [0, 0, 2, 0], [0, 3, 0, 0], [0, 0, 0, 1]]
      )
      cm3d = AffineTransform.from_params("ijk", "xyz", aff)
      cm2d = drop_io_dim(cm3d, "z")
      assert_array_equal(cm2d.affine, np.diag([1, 2, 1]))
      cm2d = drop_io_dim(cm3d, "k")
      assert_array_equal(cm2d.affine, np.diag([1, 3, 1]))
      # and with zeros scaling fix for orthogonal dropped dimension
      aff[2] = 0
      cm3d = AffineTransform.from_params("ijk", "xyz", aff)
      cm2d = drop_io_dim(cm3d, "z")
      assert_array_equal(cm2d.affine, np.diag([1, 2, 1]))
      # Unless told otherwise
      cm2d = drop_io_dim(cm3d, "z", fix0=False)
      # In this case we drop z because it has no matching input
      assert_array_equal(
          cm2d.affine, [[1, 0, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]
      )
      # Don't zero-fix untested dimensions
      cm2d = drop_io_dim(cm3d, "y", fix0=True)
      assert_array_equal(cm2d.affine, np.diag([1, 0, 1]))
      # Test test for ambiguous coordinate names
      # This one is OK because they match
      cm3d = AffineTransform.from_params(
          "ijk", "iyz", np.diag([1, 2, 3, 1])
      )
      cm2d = drop_io_dim(cm3d, "i")
      assert_array_equal(cm2d.affine, np.diag([2, 3, 1]))
      # Here they don't match and this raises an error
      cm3d = AffineTransform.from_params(
          "ijk", "xiz", np.diag([1, 2, 3, 1])
      )
      pytest.raises(AxisError, drop_io_dim, cm3d, "i")
      # Dropping input or outputs that have no matching dimensions is also OK
      aff = np.array(
          [
              [1, 0.1, 0, 10],
              [0.1, 0, 0, 11],
              [0, 3, 0, 12],
              [0, 0, 0, 1],
          ]
      )
      cm3d = AffineTransform.from_params("ijk", "xyz", aff)
      cm2d = drop_io_dim(cm3d, "k")
      assert_array_equal(
          cm2d.affine,
          [[1, 0.1, 10], [0.1, 0, 11], [0, 3, 12], [0, 0, 1]],
      )
      aff = np.array(
          [
              [1, 0.1, 0, 10],
              [0, 0, 0, 11],
              [0, 3, 0.1, 12],
              [0, 0, 0, 1],
          ]
      )
      cm3d = AffineTransform.from_params("ijk", "xyz", aff)
      cm2d = drop_io_dim(cm3d, "y")
      assert_array_equal(
          cm2d.affine, [[1, 0.1, 0, 10], [0, 3, 0.1, 12], [0, 0, 0, 1]]
      )
  
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 34 for calling a global function with example usage: test_drop_io_dim() without return types