Grouping 2D data using Python
class Point: def __init__(self, x=None, y=None): self.x = x self.y = y self.xy_list = [x, y] def __eq__(self, other): if isinstance(other, Point): if self.x in other.xy_list or self.y in other.xy_list: other.xy_list.append(self.x) other.xy_list.append(self.y) return True return False def __hash__(self): return hash((self.x, self.y)) def __str__(self): return str(self.x) + “–” + str(self.y) def group_by_point(p_list): d = dict() for […]