25 from .polygon 
import Polygon
 
   31         return f
"{self.__class__.__name__}({[p for p in self.getVertices()]})" 
   34         return self.__class__, (self.getVertices(),)
 
   37         """Iterator over vertices""" 
   38         vertices = self.getVertices()
 
   41     def __getitem__(self, i):
 
   42         return [pt 
for pt 
in self][i]
 
   45         return self.getNumEdges()
 
   47     def __contains__(self, point):
 
   48         """point in polygon?""" 
   49         return self.contains(point)
 
   51     def display(self, xy0=None, frame=1, ctype=None):
 
   52         """Display polygon on existing frame""" 
   56         disp = afwDisplay.Display(frame=frame)
 
   57         with disp.Buffering():
 
   58             for p1, p2 
in self.getEdges():
 
   59                 disp.line((p1 - xy0, p2 - xy0), ctype=ctype)
 
   61     def plot(self, axes=None, **kwargs):
 
   62         """Plot polygon with matplotlib 
   66         axes : `matplotlib.axes.Axes` 
   67             Matplotlib axes to use, or None 
   69             Additional arguments to `matplotlib.axes.Axes.plot` 
   70             or `matplotlib.axes.Axes.scatter`. 
   74         axes : `matplotlib.axes.Axes` 
   75             The axes used to make the plot (same as ``axes``, if provided). 
   79             import matplotlib.pyplot 
as plt
 
   82         for p1, p2 
in self.getEdges():
 
   83             x = (p1.getX(), p2.getX())
 
   84             y = (p1.getY(), p2.getY())
 
   85             axes.plot(x, y, **kwargs)
 
   86         vertices = self.getVertices()
 
   87         x = numpy.array([p[0] 
for p 
in vertices])
 
   88         y = numpy.array([p[1] 
for p 
in vertices])
 
   89         axes.scatter(x, y, **kwargs)