code: def test_xyz_space():
      # Space objects
      sp = XYZSpace("hijo")
      assert sp.name == "hijo"
      exp_labels = ["hijo-" + L for L in ("x=L->R", "y=P->A", "z=I->S")]
      exp_map = dict(zip("xyz", exp_labels))
      assert [sp.x, sp.y, sp.z] == exp_labels
      assert sp.as_tuple() == tuple(exp_labels)
      assert sp.as_map() == exp_map
      known = {}
      sp.register_to(known)
      assert known == dict(zip(exp_labels, "xyz"))
      # Coordinate system making, and __contains__ tests
      csm = sp.to_coordsys_maker()
      cs = csm(2)
      assert cs == CS(exp_labels[:2], "hijo")
      # This is only 2 dimensions, not fully in space
      assert cs not in sp
      cs = csm(3)
      assert cs == CS(exp_labels, "hijo")
      # We now have all 3, this in in the space
      assert cs in sp
      # More dimensions than default, error
      pytest.raises(CoordSysMakerError, csm, 4)
      # But we can pass in names for further dimensions
      csm = sp.to_coordsys_maker("tuv")
      cs = csm(6)
      assert cs == CS(exp_labels + list("tuv"), "hijo")
      # These are also in the space, because they contain xyz
      assert cs in sp
      # The axes can be in any order as long as they are a subset
      cs = CS(exp_labels, "hijo")
      assert cs in sp
      cs = CS(exp_labels[::-1], "hijo")
      assert cs in sp
      cs = CS(["t"] + exp_labels, "hijo")
      assert cs in sp
      # The coordinate system name doesn't matter
      cs = CS(exp_labels, "hija")
      assert cs in sp
      # Images, and coordinate maps, also work
      cmap = AffineTransform("ijk", cs, np.eye(4))
      assert cmap in sp
      img = Image(np.zeros((2, 3, 4)), cmap)
      assert img in sp
      # equality
      assert XYZSpace("hijo") == XYZSpace("hijo")
      assert XYZSpace("hijo") != XYZSpace("hija")
  
file_path: nipy/nipy/core/reference/tests/test_spaces.py
imports: import numpy
  import pytest
  from nibabel.affines import from_matvec
  from numpy.testing import assert_array_equal
  from ...image.image import Image
  from ..coordinate_map import AffineTransform, CoordinateMap
  from ..coordinate_system import CoordinateSystem
  from ..coordinate_system import CoordSysMakerError
  from ..spaces import AffineError, AxesError, SpaceError, SpaceTypeError, XYZSpace, get_world_cs, is_xyz_affable, is_xyz_space, known_space, known_spaces, mni_csm, mni_space, vox2aligned, vox2mni, vox2scanner, vox2talairach, vox2unknown, xyz_affine, xyz_order
label_desc: Use image node_id 2 for calling a global function with example usage: test_xyz_space() without return types