MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_internal_cpp_api

Function test_internal_cpp_api

lib/matplotlib/tests/test_triangulation.py:1186–1274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1184
1185
1186def test_internal_cpp_api() -> None:
1187 # Following github issue 8197.
1188 from matplotlib import _tri # noqa: F401, ensure lazy-loaded module *is* loaded.
1189
1190 # C++ Triangulation.
1191 with pytest.raises(
1192 TypeError,
1193 match=r'__init__\(\): incompatible constructor arguments.'):
1194 mpl._tri.Triangulation() # type: ignore[call-arg]
1195
1196 with pytest.raises(
1197 ValueError, match=r'x and y must be 1D arrays of the same length'):
1198 mpl._tri.Triangulation(np.array([]), np.array([1]), np.array([[]]), (), (), (),
1199 False)
1200
1201 x = np.array([0, 1, 1], dtype=np.float64)
1202 y = np.array([0, 0, 1], dtype=np.float64)
1203 with pytest.raises(
1204 ValueError,
1205 match=r'triangles must be a 2D array of shape \(\?,3\)'):
1206 mpl._tri.Triangulation(x, y, np.array([[0, 1]]), (), (), (), False)
1207
1208 tris = np.array([[0, 1, 2]], dtype=np.int_)
1209 with pytest.raises(
1210 ValueError,
1211 match=r'mask must be a 1D array with the same length as the '
1212 r'triangles array'):
1213 mpl._tri.Triangulation(x, y, tris, np.array([0, 1]), (), (), False)
1214
1215 with pytest.raises(
1216 ValueError, match=r'edges must be a 2D array with shape \(\?,2\)'):
1217 mpl._tri.Triangulation(x, y, tris, (), np.array([[1]]), (), False)
1218
1219 with pytest.raises(
1220 ValueError,
1221 match=r'neighbors must be a 2D array with the same shape as the '
1222 r'triangles array'):
1223 mpl._tri.Triangulation(x, y, tris, (), (), np.array([[-1]]), False)
1224
1225 triang = mpl._tri.Triangulation(x, y, tris, (), (), (), False)
1226
1227 with pytest.raises(
1228 ValueError,
1229 match=r'z must be a 1D array with the same length as the '
1230 r'triangulation x and y arrays'):
1231 triang.calculate_plane_coefficients([])
1232
1233 for mask in ([0, 1], None):
1234 with pytest.raises(
1235 ValueError,
1236 match=r'mask must be a 1D array with the same length as the '
1237 r'triangles array'):
1238 triang.set_mask(mask) # type: ignore[arg-type]
1239
1240 triang.set_mask(np.array([True]))
1241 assert_array_equal(triang.get_edges(), np.empty((0, 2)))
1242
1243 triang.set_mask(()) # Equivalent to Python Triangulation mask=None

Callers

nothing calls this directly

Calls 2

set_maskMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…