code: def test_internal_cpp_api():
      # Following github issue 8197.
      from matplotlib import (
          _tri,
      )  # noqa: ensure lazy-loaded module *is* loaded.
  
      # C++ Triangulation.
      with pytest.raises(
          TypeError,
          match=r"__init__\(\): incompatible constructor arguments.",
      ):
          mpl._tri.Triangulation()
  
      with pytest.raises(
          ValueError,
          match=r"x and y must be 1D arrays of the same length",
      ):
          mpl._tri.Triangulation([], [1], [[]], (), (), (), False)
  
      x = [0, 1, 1]
      y = [0, 0, 1]
      with pytest.raises(
          ValueError,
          match=r"triangles must be a 2D array of shape \(\?,3\)",
      ):
          mpl._tri.Triangulation(x, y, [[0, 1]], (), (), (), False)
  
      tris = [[0, 1, 2]]
      with pytest.raises(
          ValueError,
          match=r"mask must be a 1D array with the same length as the "
          r"triangles array",
      ):
          mpl._tri.Triangulation(x, y, tris, [0, 1], (), (), False)
  
      with pytest.raises(
          ValueError,
          match=r"edges must be a 2D array with shape \(\?,2\)",
      ):
          mpl._tri.Triangulation(x, y, tris, (), [[1]], (), False)
  
      with pytest.raises(
          ValueError,
          match=r"neighbors must be a 2D array with the same shape as the "
          r"triangles array",
      ):
          mpl._tri.Triangulation(x, y, tris, (), (), [[-1]], False)
  
      triang = mpl._tri.Triangulation(x, y, tris, (), (), (), False)
  
      with pytest.raises(
          ValueError,
          match=r"z must be a 1D array with the same length as the "
          r"triangulation x and y arrays",
      ):
          triang.calculate_plane_coefficients([])
  
      for mask in ([0, 1], None):
          with pytest.raises(
              ValueError,
              match=r"mask must be a 1D array with the same length as the "
              r"triangles array",
          ):
              triang.set_mask(mask)
  
      triang.set_mask([True])
      assert_array_equal(triang.get_edges(), np.empty((0, 2)))
  
      triang.set_mask(
          ()
      )  # Equivalent to Python Triangulation mask=None
      assert_array_equal(triang.get_edges(), [[1, 0], [2, 0], [2, 1]])
  
      # C++ TriContourGenerator.
      with pytest.raises(
          TypeError,
          match=r"__init__\(\): incompatible constructor arguments.",
      ):
          mpl._tri.TriContourGenerator()
  
      with pytest.raises(
          ValueError,
          match=r"z must be a 1D array with the same length as the x and y "
          r"arrays",
      ):
          mpl._tri.TriContourGenerator(triang, [1])
  
      z = [0, 1, 2]
      tcg = mpl._tri.TriContourGenerator(triang, z)
  
      with pytest.raises(
          ValueError, match=r"filled contour levels must be increasing"
      ):
          tcg.create_filled_contour(1, 0)
  
      # C++ TrapezoidMapTriFinder.
      with pytest.raises(
          TypeError,
          match=r"__init__\(\): incompatible constructor arguments.",
      ):
          mpl._tri.TrapezoidMapTriFinder()
  
      trifinder = mpl._tri.TrapezoidMapTriFinder(triang)
  
      with pytest.raises(
          ValueError,
          match=r"x and y must be array-like with same shape",
      ):
          trifinder.find_many([0], [0, 1])
  
imports: import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_array_less
  import numpy.ma.testutils
  import pytest
  import matplotlib
  import matplotlib.pyplot
  import matplotlib.tri
  from matplotlib.path import Path
  from matplotlib.testing.decorators import image_comparison, check_figures_equal
label_desc: Use image node_id 32 for calling a global function with example usage: test_internal_cpp_api() without return types