Skip to content

Commit 652371f

Browse files
committed
Test path containment w/ nonlin. transforms; group containment tests.
1 parent 050b20c commit 652371f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

lib/matplotlib/tests/test_path.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ def test_contains_points_negative_radius():
4646
assert np.all(result == expected)
4747

4848

49+
def test_point_in_path_nan():
50+
box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
51+
p = Path(box)
52+
test = np.array([[np.nan, 0.5]])
53+
contains = p.contains_points(test)
54+
assert len(contains) == 1
55+
assert not contains[0]
56+
57+
58+
def test_nonlinear_containment():
59+
fig, ax = plt.subplots()
60+
ax.set(xscale="log", ylim=(0, 1))
61+
polygon = ax.axvspan(1, 10)
62+
assert polygon.get_path().contains_point(
63+
ax.transData.transform_point((5, .5)), ax.transData)
64+
65+
4966
@image_comparison(baseline_images=['path_clipping'],
5067
extensions=['svg'], remove_text=True)
5168
def test_path_clipping():
@@ -67,15 +84,6 @@ def test_path_clipping():
6784
xy, facecolor='none', edgecolor='red', closed=True))
6885

6986

70-
def test_point_in_path_nan():
71-
box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
72-
p = Path(box)
73-
test = np.array([[np.nan, 0.5]])
74-
contains = p.contains_points(test)
75-
assert len(contains) == 1
76-
assert not contains[0]
77-
78-
7987
@image_comparison(baseline_images=['semi_log_with_zero'], extensions=['png'])
8088
def test_log_transform_with_zero():
8189
x = np.arange(-10, 10)

0 commit comments

Comments
 (0)