()
| 1371 | |
| 1372 | |
| 1373 | def test_tricontourf_path(): |
| 1374 | x = [0, 4, 4, 0, 2] |
| 1375 | y = [0, 0, 4, 4, 2] |
| 1376 | triang = mtri.Triangulation(x, y) |
| 1377 | _, ax = plt.subplots() |
| 1378 | |
| 1379 | # Polygon inside domain |
| 1380 | cs = ax.tricontourf(triang, [0, 0, 0, 0, 1], levels=[0.5, 1.5]) |
| 1381 | paths = cs.get_paths() |
| 1382 | assert len(paths) == 1 |
| 1383 | expected_vertices = [[3, 1], [3, 3], [1, 3], [1, 1], [3, 1]] |
| 1384 | assert_array_almost_equal(paths[0].vertices, expected_vertices) |
| 1385 | assert_array_equal(paths[0].codes, [1, 2, 2, 2, 79]) |
| 1386 | assert_array_almost_equal(paths[0].to_polygons(), [expected_vertices]) |
| 1387 | |
| 1388 | # Polygon following boundary and inside domain |
| 1389 | cs = ax.tricontourf(triang, [1, 0, 0, 0, 0], levels=[0.5, 1.5]) |
| 1390 | paths = cs.get_paths() |
| 1391 | assert len(paths) == 1 |
| 1392 | expected_vertices = [[2, 0], [1, 1], [0, 2], [0, 0], [2, 0]] |
| 1393 | assert_array_almost_equal(paths[0].vertices, expected_vertices) |
| 1394 | assert_array_equal(paths[0].codes, [1, 2, 2, 2, 79]) |
| 1395 | assert_array_almost_equal(paths[0].to_polygons(), [expected_vertices]) |
| 1396 | |
| 1397 | # Polygon is outer boundary with hole |
| 1398 | cs = ax.tricontourf(triang, [0, 0, 0, 0, 1], levels=[-0.5, 0.5]) |
| 1399 | paths = cs.get_paths() |
| 1400 | assert len(paths) == 1 |
| 1401 | expected_vertices = [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0], |
| 1402 | [1, 1], [1, 3], [3, 3], [3, 1], [1, 1]] |
| 1403 | assert_array_almost_equal(paths[0].vertices, expected_vertices) |
| 1404 | assert_array_equal(paths[0].codes, [1, 2, 2, 2, 79, 1, 2, 2, 2, 79]) |
| 1405 | assert_array_almost_equal(paths[0].to_polygons(), np.split(expected_vertices, [5])) |
nothing calls this directly
no test coverage detected
searching dependent graphs…