()
| 567 | |
| 568 | |
| 569 | def test_find_nearest_contour(): |
| 570 | xy = np.indices((15, 15)) |
| 571 | img = np.exp(-np.pi * (np.sum((xy - 5)**2, 0)/5.**2)) |
| 572 | cs = plt.contour(img, 10) |
| 573 | |
| 574 | nearest_contour = cs.find_nearest_contour(1, 1, pixel=False) |
| 575 | expected_nearest = (1, 0, 33, 1.965966, 1.965966, 1.866183) |
| 576 | assert_array_almost_equal(nearest_contour, expected_nearest) |
| 577 | |
| 578 | nearest_contour = cs.find_nearest_contour(8, 1, pixel=False) |
| 579 | expected_nearest = (1, 0, 5, 7.550173, 1.587542, 0.547550) |
| 580 | assert_array_almost_equal(nearest_contour, expected_nearest) |
| 581 | |
| 582 | nearest_contour = cs.find_nearest_contour(2, 5, pixel=False) |
| 583 | expected_nearest = (3, 0, 21, 1.884384, 5.023335, 0.013911) |
| 584 | assert_array_almost_equal(nearest_contour, expected_nearest) |
| 585 | |
| 586 | nearest_contour = cs.find_nearest_contour(2, 5, indices=(5, 7), pixel=False) |
| 587 | expected_nearest = (5, 0, 16, 2.628202, 5.0, 0.394638) |
| 588 | assert_array_almost_equal(nearest_contour, expected_nearest) |
| 589 | |
| 590 | |
| 591 | def test_find_nearest_contour_no_filled(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…