8000 add test_contains_point and test_contains_points · matplotlib/matplotlib@aef6721 · GitHub
[go: up one dir, main page]

Skip to content

Commit aef6721

Browse files
committed
add test_contains_point and test_contains_points
1 parent 0d1d731 commit aef6721

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/matplotlib/tests/test_patches.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,27 @@ def test_datetime_datetime_fails():
386386

387387
with pytest.raises(TypeError):
388388
mpatches.Rectangle((0, start), 1, dt_delta)
389+
390+
391+
def test_contains_point():
392+
ell = mpatches.Ellipse((0.5, 0.5), 0.5, 1.0, 0)
393+
points = [(0.0, 0.5), (0.2, 0.5), (0.25, 0.5), (0.5, 0.5)]
394+
path = ell.get_path()
395+
transform = ell.get_transform()
396+
radius = ell._process_radius(None)
397+
expected = np.array([path.contains_point(point,
398+
transform,
399+
radius) for point in points])
400+
result = np.array([ell.contains_point(point) for point in points])
401+
assert np.all(result == expected)
402+
403+
404+
def test_contains_points():
405+
ell = mpatches.Ellipse((0.5, 0.5), 0.5, 1.0, 0)
406+
points = [(0.0, 0.5), (0.2, 0.5), (0.25, 0.5), (0.5, 0.5)]
407+
path = ell.get_path()
408+
transform = ell.get_transform()
409+
radius = ell._process_radius(None)
410+
expected = path.contains_points(points, transform, radius)
411+
result = ell.contains_points(points)
412+
assert np.all(result == expected)

0 commit comments

Comments
 (0)
0