Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee9f02b

Browse files
committed
Merge pull request #6 from mdboom/hatch_clipping_v1.2.x
Don't overwrite unit_circle vertices in clipping test
2 parents deb211f + c0e2e48 commit ee9f02b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

lib/matplotlib/tests/test_artist.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@
1818
def test_patch_transform_of_none():
1919
# tests the behaviour of patches added to an Axes with various transform
2020
# specifications
21-
21+
2222
ax = plt.axes()
2323
ax.set_xlim([1, 3])
2424
ax.set_ylim([1, 3])
25-
25+
2626
# Draw an ellipse over data coord (2,2) by specifying device coords.
2727
xy_data = (2, 2)
2828
xy_pix = ax.transData.transform_point(xy_data)
29-
29+
3030
# Not providing a transform of None puts the ellipse in data coordinates .
3131
e = mpatches.Ellipse(xy_data, width=1, height=1, fc='yellow', alpha=0.5)
3232
ax.add_patch(e)
3333
assert e._transform == ax.transData
34-
34+
3535
# Providing a transform of None puts the ellipse in device coordinates.
36-
e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
36+
e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
3737
transform=None, alpha=0.5)
3838
assert e.is_transform_set() is True
3939
ax.add_patch(e)
4040
assert isinstance(e._transform, mtrans.IdentityTransform)
41-
41+
4242
# Providing an IdentityTransform puts the ellipse in device coordinates.
43-
e = mpatches.Ellipse(xy_pix, width=100, height=100,
43+
e = mpatches.Ellipse(xy_pix, width=100, height=100,
4444
transform=mtrans.IdentityTransform(), alpha=0.5)
4545
ax.add_patch(e)
4646
assert isinstance(e._transform, mtrans.IdentityTransform)
@@ -55,39 +55,39 @@ def test_patch_transform_of_none():
5555
assert e.get_transform() != intermediate_transform
5656
assert e.is_transform_set() is True
5757
assert e._transform == ax.transData
58-
58+
5959

6060
@cleanup
6161
def test_collection_transform_of_none():
62-
# tests the behaviour of collections added to an Axes with various
62+
# tests the behaviour of collections added to an Axes with various
6363
# transform specifications
6464

6565
ax = plt.axes()
6666
ax.set_xlim([1, 3])
6767
ax.set_ylim([1, 3])
68-
68+
6969
#draw an ellipse over data coord (2,2) by specifying device coords
7070
xy_data = (2, 2)
7171
xy_pix = ax.transData.transform_point(xy_data)
72-
73-
# not providing a transform of None puts the ellipse in data coordinates
72+
73+
# not providing a transform of None puts the ellipse in data coordinates
7474
e = mpatches.Ellipse(xy_data, width=1, height=1)
7575
c = mcollections.PatchCollection([e], facecolor='yellow', alpha=0.5)
7676
ax.add_collection(c)
77-
# the collection should be in data coordinates
77+
# the collection should be in data coordinates
7878
assert c.get_offset_transform() + c.get_transform() == ax.transData
79-
79+
8080
# providing a transform of None puts the ellipse in device coordinates
8181
e = mpatches.Ellipse(xy_pix, width=120, height=120)
82-
c = mcollections.PatchCollection([e], facecolor='coral',
82+
c = mcollections.PatchCollection([e], facecolor='coral',
8383
alpha=0.5)
84-
c.set_transform(None)
84+
c.set_transform(None)
8585
ax.add_collection(c)
8686
assert isinstance(c.get_transform(), mtrans.IdentityTransform)
87-
87+
8888
# providing an IdentityTransform puts the ellipse in device coordinates
8989
e = mpatches.Ellipse(xy_pix, width=100, height=100)
90-
c = mcollections.PatchCollection([e], transform=mtrans.IdentityTransform(),
90+
c = mcollections.PatchCollection([e], transform=mtrans.IdentityTransform(),
9191
alpha=0.5)
9292
ax.add_collection(c)
9393
assert isinstance(c._transOffset, mtrans.IdentityTransform)
@@ -100,7 +100,7 @@ def test_point_in_path():
100100
path = mpath.Path(verts2, closed=True)
101101
points = [(0.5,0.5), (1.5,0.5)]
102102

103-
assert np.all(path.contains_points(points) == [True, False])
103+
assert np.all(path.contains_points(points) == [True, False])
104104

105105

106106
@image_comparison(baseline_images=["clip_path_clipping"], remove_text=True)
@@ -111,6 +111,8 @@ def test_clipping():
111111
exterior.vertices *= 4
112112
exterior.vertices -= 2
113113
interior = mpath.Path.unit_circle()
114+
interior = mpath.Path(copy.deepcopy(interior.vertices),
115+
copy.deepcopy(interior.codes[:]))
114116
interior.vertices = interior.vertices[::-1]
115117
clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices,
116118
interior.vertices]),
@@ -125,7 +127,7 @@ def test_clipping():
125127
facecolor='red', alpha=0.7, hatch='*')
126128
col.set_clip_path(clip_path, ax1.transData)
127129
ax1.add_collection(col)
128-
130+
129131
ax2 = plt.subplot(122, sharex=ax1, sharey=ax1)
130132
patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red',
131133
alpha=0.7, hatch='*')

0 commit comments

Comments
 (0)