code: def remove_polygons(self, test):
          
          empty = []
          for element in self.elements:
              if isinstance(element, PolygonSet):
                  ii = 0
                  while ii < len(element.polygons):
                      if test(element.polygons[ii], element.layers[ii],
                              element.datatypes[ii]):
                          element.polygons.pop(ii)
                          element.layers.pop(ii)
                          element.datatypes.pop(ii)
                      else:
                          ii += 1
                  if len(element.polygons) == 0:
                      empty.append(element)
          for element in empty:
              self.elements.remove(element)
          return self
docs: Remove polygons from this cell.
  
          The function or callable ``test`` is called for each polygon in
          the cell.  If its return value evaluates to ``True``, the
          corresponding polygon is removed from the cell.
  
          Parameters
          ----------
          test : callable
              Test function to query whether a polygon should be removed.
              The function is called with arguments:
              ``(points, layer, datatype)``
  
          Returns
          -------
          out : ``Cell``
              This cell.
  
          Examples
          --------
          Remove polygons in layer 1:
  
          >>> cell.remove_polygons(lambda pts, layer, datatype:
          ...                      layer == 1)
  
          Remove polygons with negative x coordinates:
  
          >>> cell.remove_polygons(lambda pts, layer, datatype:
          ...                      any(pts[:, 0] < 0))