Improve error handling

This commit is contained in:
jan 2017-09-06 01:14:46 -07:00
parent 934bfcd74e
commit 3d52566016

View File

@ -31,7 +31,7 @@ class Polygon(Shape):
@vertices.setter @vertices.setter
def vertices(self, val: numpy.ndarray): def vertices(self, val: numpy.ndarray):
val = numpy.array(val, dtype=float) val = numpy.array(val, dtype=float)
if val.shape[1] != 2: if len(val.shape) < 2 or val.shape[1] != 2:
raise PatternError('Vertices must be an Nx2 array') raise PatternError('Vertices must be an Nx2 array')
if val.shape[0] < 3: if val.shape[0] < 3:
raise PatternError('Must have at least 3 vertices (Nx2, N>3)') raise PatternError('Must have at least 3 vertices (Nx2, N>3)')