def _group_dict_set ( iterator ) : d = defaultdict ( set ) for key , value in iterator : d [ key ] . add ( value ) return dict ( d )
mapping a set with a dictionary in python
Make a dict that accumulates the values for each key in an iterator of doubles .
def _group_dict_set(iterator):
    """Make a dict that accumulates the values for each key in an iterator of doubles.

    :param iter[tuple[A,B]] iterator: An iterator
    :rtype: dict[A,set[B]]
    """
    d = defaultdict(set)
    for key, value in iterator:
        d[key].add(value)
    return dict(d)