def get_polygons(self, by_spec=False, depth=None):
        """
        Returns a list of polygons in this cell.

        Parameters
        ----------
        by_spec : bool
            If ``True``, the return value is a dictionary with the
            polygons of each individual pair (layer, datatype).
        depth : integer or ``None``
            If not ``None``, defines from how many reference levels to
            retrieve polygons.  References below this level will result
            in a bounding box.  If ``by_spec`` is ``True`` the key will
            be the name of this cell.

        Returns
        -------
        out : list of array-like[N][2] or dictionary
            List containing the coordinates of the vertices of each
            polygon, or dictionary with the list of polygons (if
            ``by_spec`` is ``True``).
        """
        if depth is not None and depth < 0:
            bb = self.get_bounding_box()
            if bb is None:
                return {} if by_spec else []
            pts = [
                numpy.array([(bb[0, 0], bb[0, 1]), (bb[0, 0], bb[1, 1]),
                             (bb[1, 0], bb[1, 1]), (bb[1, 0], bb[0, 1])])
            ]
            polygons = {self.name: pts} if by_spec else pts
        else:
            if by_spec:
                polygons = {}
                for element in self.elements:
                    if isinstance(element, PolygonSet):
                        for ii in range(len(element.polygons)):
                            key = (element.layers[ii], element.datatypes[ii])
                            if key in polygons:
                                polygons[key].append(
                                    numpy.array(element.polygons[ii]))
                            else:
                                polygons[key] = [
                                    numpy.array(element.polygons[ii])
                                ]
                    else:
                        cell_polygons = element.get_polygons(
                            True, None if depth is None else depth - 1)
                        for kk in cell_polygons.keys():
                            if kk in polygons:
                                polygons[kk].extend(cell_polygons[kk])
                            else:
                                polygons[kk] = cell_polygons[kk]
            else:
                polygons = []
                for element in self.elements:
                    if isinstance(element, PolygonSet):
                        for points in element.polygons:
                            polygons.append(numpy.array(points))
                    else:
                        polygons.extend(
                            element.get_polygons(
                                depth=None if depth is None else depth - 1))
        return polygons
Returns a list of polygons in this cell.

        Parameters
        ----------
        by_spec : bool
            If ``True``, the return value is a dictionary with the
            polygons of each individual pair (layer, datatype).
        depth : integer or ``None``
            If not ``None``, defines from how many reference levels to
            retrieve polygons.  References below this level will result
            in a bounding box.  If ``by_spec`` is ``True`` the key will
            be the name of this cell.

        Returns
        -------
        out : list of array-like[N][2] or dictionary
            List containing the coordinates of the vertices of each
            polygon, or dictionary with the list of polygons (if
            ``by_spec`` is ``True``).