Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test_patches: add to list of default tests, add docstrings

  • Loading branch information...
commit a23cd4d0fb76a49382068d9d0a3d714d31fbbcdd 1 parent 275c6e3
@efiring authored
Showing with 29 additions and 2 deletions.
  1. +1 −0  lib/matplotlib/__init__.py
  2. +28 −2 lib/matplotlib/tests/test_patches.py
View
1  lib/matplotlib/__init__.py
@@ -1020,6 +1020,7 @@ def tk_window_focus():
'matplotlib.tests.test_delaunay',
'matplotlib.tests.test_legend',
'matplotlib.tests.test_colorbar',
+ 'matplotlib.tests.test_patches',
]
def test(verbosity=1):
View
30 lib/matplotlib/tests/test_patches.py
@@ -1,16 +1,42 @@
+"""
+Tests specific to the patches module.
+"""
+
from numpy.testing import assert_array_equal
from matplotlib.patches import Polygon
def test_Polygon_close():
- #1018
+ """
+ Github issue #1018 identified a bug in the Polygon handling
+ of the closed attribute; the path was not getting closed
+ when set_xy was used to set the vertices.
+ """
+ # open set of vertices:
xy = [[0,0], [0,1], [1,1]]
+ # closed set:
xyclosed = xy + [[0,0]]
+
+ # start with open path and close it:
p = Polygon(xy, closed=True)
assert_array_equal(p.get_xy(), xyclosed)
p.set_xy(xy)
assert_array_equal(p.get_xy(), xyclosed)
- p = Polygon(xy, closed=False)
+
+ # start with closed path and open it:
+ p = Polygon(xyclosed, closed=False)
assert_array_equal(p.get_xy(), xy)
p.set_xy(xyclosed)
assert_array_equal(p.get_xy(), xy)
+ # start with open path and leave it open:
+ p = Polygon(xy, closed=False)
+ assert_array_equal(p.get_xy(), xy)
+ p.set_xy(xy)
+ assert_array_equal(p.get_xy(), xy)
+
+ # start with closed path and leave it closed:
+ p = Polygon(xyclosed, closed=True)
+ assert_array_equal(p.get_xy(), xyclosed)
+ p.set_xy(xyclosed)
+ assert_array_equal(p.get_xy(), xyclosed)
+
Please sign in to comment.
Something went wrong with that request. Please try again.