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

Skip to content

Commit 35d1e83

Browse files
committed
Add test for rect rotation
1 parent 6f49939 commit 35d1e83

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/matplotlib/tests/test_patches.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ def test_rotate_rect():
7676
assert_almost_equal(rect1.get_verts(), new_verts)
7777

7878

79+
@check_figures_equal(extensions=['png'])
80+
def test_rotate_rect_draw(fig_test, fig_ref):
81+
ax_test = fig_test.add_subplot()
82+
ax_ref = fig_ref.add_subplot()
83+
84+
loc = (0, 0)
85+
width, height = (1, 1)
86+
angle = 30
87+
rect_ref = Rectangle(loc, width, height, angle=angle)
88+
ax_ref.add_patch(rect_ref)
89+
assert rect_ref.get_angle() == angle
90+
91+
# Check that when the angle is updated after adding to an axes, that the
92+
# patch is marked stale and redrawn in the correct location
93+
rect_test = Rectangle(loc, width, height)
94+
assert rect_test.get_angle() == 0
95+
ax_test.add_patch(rect_test)
96+
rect_test.set_angle(angle)
97+
assert rect_test.get_angle() == angle
98+
99+
79100
def test_negative_rect():
80101
# These two rectangles have the same vertices, but starting from a
81102
# different point. (We also drop the last vertex, which is a duplicate.)

0 commit comments

Comments
 (0)