def cluster_dumb(list, window, key, value): """The full O(N^2) clustering algorithm, but easier to verify correctness.""" return [ item for item in list if all( abs(key(item) - key(other)) >= window or value(item) >= value(other) for other in list) ]
def is_heap(self): return all(self._cmp(i, (i - 1) / 2) == -1 for i in range(1, len(self._heap)))