8000 Test path containment w/ nonlin. transforms; group containment tests. · matplotlib/matplotlib@76173e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 76173e1

Browse files
committed
Test path containment w/ nonlin. transforms; group containment tests.
1 parent 15eb7e7 commit 76173e1

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lib/matplotlib/tests/test_path.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ def test_contains_points_negative_radius():
4545
assert np.all(result == expected)
4646

4747

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

6889

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

0 commit comments

Comments
 (0)
0