[Polygon.rect] raise a PatternError when given the wrong number of args

instead of assert
This commit is contained in:
Jan Petykiewicz 2026-01-19 18:35:13 -08:00
parent 28e2864ce1
commit 48034b7a30

View File

@ -256,6 +256,11 @@ class Polygon(Shape):
Returns: Returns:
A Polygon object containing the requested rectangle A Polygon object containing the requested rectangle
""" """
if sum(int(pp is None) for pp in (xmin, xmax, xctr, lx)) != 2:
raise PatternError('Exactly two of xmin, xctr, xmax, lx must be provided!')
if sum(int(pp is None) for pp in (ymin, ymax, yctr, ly)) != 2:
raise PatternError('Exactly two of ymin, yctr, ymax, ly must be provided!')
if lx is None: if lx is None:
if xctr is None: if xctr is None:
assert xmin is not None assert xmin is not None