code: def test_transforms():
      # test transform mapping between nodes
      root = Node()
      n1 = Node(parent=root)
      n2 = Node(parent=n1)
      n3 = Node(parent=root)
      n4 = Node(parent=n3)
  
      n1.transform = STTransform(scale=(0.1, 0.1), translate=(7, 6))
      n2.transform = STTransform(scale=(0.2, 0.3), translate=(5, 4))
      n3.transform = STTransform(scale=(0.4, 0.5), translate=(3, 2))
      n4.transform = STTransform(scale=(0.6, 0.7), translate=(1, 0))
  
      assert np.allclose(n1.transform.map((0, 0))[:2], (7, 6))
      assert np.allclose(
          n1.node_transform(root).map((0, 0))[:2], (7, 6)
      )
      assert np.allclose(n2.transform.map((0, 0))[:2], (5, 4))
      assert np.allclose(
          n2.node_transform(root).map((0, 0))[:2],
          (5 * 0.1 + 7, 4 * 0.1 + 6),
      )
      assert np.allclose(
          root.node_transform(n1).map((0, 0))[:2], (-7 / 0.1, -6 / 0.1)
      )
      assert np.allclose(
          root.node_transform(n2).map((0, 0))[:2],
          ((-7 / 0.1 - 5) / 0.2, (-6 / 0.1 - 4) / 0.3),
      )
  
      # just check that we can assemble transforms correctly mapping across the
      # scenegraph
      assert n2.node_path(n4) == ([n2, n1, root], [n3, n4])
      assert n4.node_path(n2) == ([n4, n3, root], [n1, n2])
      assert n2.node_path(root) == ([n2, n1, root], [])
      assert root.node_path(n4) == ([root], [n3, n4])
      assert n2.node_path_transforms(n4) == [
          n4.transform.inverse,
          n3.transform.inverse,
          n1.transform,
          n2.transform,
      ]
      assert n4.node_path_transforms(n2) == [
          n2.transform.inverse,
          n1.transform.inverse,
          n3.transform,
          n4.transform,
      ]
  
      pts = np.array([[0, 0], [1, 1], [-56.3, 800.2]])
      assert np.all(
          n2.node_transform(n1).map(pts) == n2.transform.map(pts)
      )
      assert np.all(
          n2.node_transform(root).map(pts)
          == n1.transform.map(n2.transform.map(pts))
      )
      assert np.all(
          n1.node_transform(n3).map(pts)
          == n3.transform.inverse.map(n1.transform.map(pts))
      )
      assert np.all(
          n2.node_transform(n3).map(pts)
          == n3.transform.inverse.map(
              n1.transform.map(n2.transform.map(pts))
          )
      )
      assert np.all(
          n2.node_transform(n4).map(pts)
          == n4.transform.inverse.map(
              n3.transform.inverse.map(
                  n1.transform.map(n2.transform.map(pts))
              )
          )
      )
  
      # test transforms still work after reparenting
      n3.parent = n1
      assert np.all(
          n2.node_transform(n4).map(pts)
          == n4.transform.inverse.map(
              n3.transform.inverse.map(n2.transform.map(pts))
          )
      )
  
      # test transform simplification
      assert np.all(
          n2.node_transform(n4).map(pts)
          == n2.node_transform(n4).simplified.map(pts)
      )
  
file_path: vispy/vispy/scene/tests/test_node.py
imports: from vispy.scene.node import Node
  from vispy.testing import requires_application, TestingCanvas, run_tests_if_main, raises
  from vispy.visuals.transforms import STTransform
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: test_transforms() without return types