code: def test_edge_intersections():
      global t
      pts = np.array(
          [
              [0, 0],
              [1, 0],
              [1, 1],
              [0, 1],
              [0, 0.5],  # three edges intersect here
              [2, 0.5],
              [-1, 0.2],
              [2, 0.8],
              [-1, 1],
              [0, 0.5],
          ]
      )
      edges = np.array(
          [
              [0, 1],
              [1, 2],
              [2, 3],
              [3, 0],
              [4, 5],
              [6, 7],
              [8, 9],
          ]
      )
  
      t = T(pts, edges)
  
      # first test find_edge_intersections
      cuts = t._find_edge_intersections()
      expect = {
          0: [],
          1: [(0.5, [1.0, 0.5]), (0.6, [1.0, 0.6])],
          2: [],
          3: [(0.5, [0.0, 0.5]), (0.6, [0.0, 0.4])],
          4: [(0.25, [0.5, 0.5]), (0.5, [1.0, 0.5])],
          5: [
              (1.0 / 3.0, [0.0, 0.4]),
              (0.5, [0.5, 0.5]),
              (2.0 / 3.0, [1.0, 0.6]),
          ],
      }
  
      assert len(expect) == len(cuts)
      for k, v in expect.items():
          assert len(v) == len(cuts[k])
          for i, ecut in enumerate(v):
              vcut = cuts[k][i]
              assert len(vcut) == len(ecut)
              for j in range(len(vcut)):
                  assert_array_almost_equal(
                      np.array(ecut[j]), np.array(vcut[j])
                  )
  
      # next test that we can split the edges correctly
      t._split_intersecting_edges()
      pts = np.array(
          [
              [0.0, 0.0],
              [1.0, 0.0],
              [1.0, 1.0],
              [0.0, 1.0],
              [0.0, 0.5],
              [2.0, 0.5],
              [-1.0, 0.2],
              [2.0, 0.8],
              [-1.0, 1.0],
              [0.0, 0.5],
              [1.0, 0.5],
              [1.0, 0.6],
              [0.0, 0.5],
              [0.0, 0.4],
              [0.5, 0.5],
              [1.0, 0.5],
              [0.0, 0.4],
              [0.5, 0.5],
              [1.0, 0.6],
          ]
      )
      edges = np.array(
          [
              [0, 1],
              [1, 10],
              [2, 3],
              [3, 12],
              [4, 14],
              [6, 16],
              [8, 9],
              [10, 11],
              [11, 2],
              [12, 13],
              [13, 0],
              [14, 15],
              [15, 5],
              [16, 17],
              [17, 18],
              [18, 7],
          ]
      )
  
      if sys.version[0] == "3":
          raise SkipTest("Triangulation differences on Py3k")
      assert_array_almost_equal(pts, t.pts)
      assert np.all(edges == t.edges)
  
      # Test _nearly_ parallel lines.
      pts = np.array(
          [
              [0.0, 0.0],
              [1.62434542, 0.0],
              [1.62434542, -0.61175638],
              [1.09617364, -0.61175638],
          ]
      )
  
      edges = np.array([[0, 1], [1, 2], [2, 3], [3, 0]])
      t = T(pts, edges)
      for edge, cuts in t._find_edge_intersections().items():
          assert len(cuts) == 0
  
file_path: vispy/vispy/geometry/tests/test_triangulation.py
imports: import sys
  from unittest import SkipTest
  import numpy
  from numpy.testing import assert_array_almost_equal
  from vispy.testing import run_tests_if_main
  from vispy.geometry.triangulation import Triangulation
label_desc: Use image node_id 3 for calling a global function with example usage: test_edge_intersections() without return types