fog/test/clustering/utils.py

21 lines
597 B
Python
Raw Normal View History

2018-06-11 15:00:59 +00:00
# =============================================================================
# Fog Clustering Unit Tests Utilities
# =============================================================================
class Clusters(object):
def __init__(self, clusters):
self.groups = set(tuple(sorted(values)) for values in clusters)
def __eq__(self, other):
return self.groups == other.groups
2018-06-12 15:24:16 +00:00
2018-06-20 10:57:43 +00:00
def __iter__(self):
2018-07-05 15:20:28 +00:00
return iter(self.groups)
def __len__(self):
return len(self.groups)
2018-06-20 10:57:43 +00:00
2018-06-12 15:24:16 +00:00
def __repr__(self):
return 'Clusters(%s)' % self.groups.__repr__()