pypet/utils/explore.py
def find_unique_points(explored_parameters):
    """Takes a list of explored parameters and finds unique parameter combinations.

    If parameter ranges are hashable operates in O(N), otherwise O(N**2).

    :param explored_parameters:

        List of **explored** parameters

    :return:

        List of tuples, first entry being the parameter values, second entry a list
        containing the run position of the unique combination.

    """
    ranges = [param.f_get_range(copy=False) for param in explored_parameters]
    zipped_tuples = list(zip(*ranges))
    try:
        unique_elements = OrderedDict()
        for idx, val_tuple in enumerate(zipped_tuples):
            if val_tuple not in unique_elements:
                unique_elements[val_tuple] = []
            unique_elements[val_tuple].append(idx)
        return list(unique_elements.items())
    except TypeError:
        logger = logging.getLogger('pypet.find_unique')
        logger.error('Your parameter entries could not be hashed, '
                     'now I am sorting slowly in O(N**2).')
        unique_elements = []
        for idx, val_tuple in enumerate(zipped_tuples):
            matches = False
            for added_tuple, pos_list in unique_elements:
                matches = True
                for idx2, val in enumerate(added_tuple):
                    if not explored_parameters[idx2]._equal_values(val_tuple[idx2], val):
                        matches = False
                        break
                if matches:
                    pos_list.append(idx)
                    break
            if not matches:
                unique_elements.append((val_tuple, [idx]))
        return unique_elements
def find_unique_points(explored_parameters):
    """Takes a list of explored parameters and finds unique parameter combinations.

    If parameter ranges are hashable operates in O(N), otherwise O(N**2).

    :param explored_parameters:

        List of **explored** parameters

    :return:

        List of tuples, first entry being the parameter values, second entry a list
        containing the run position of the unique combination.

    """
    ranges = [param.f_get_range(copy=False) for param in explored_parameters]
    zipped_tuples = list(zip(*ranges))
    try:
        unique_elements = OrderedDict()
        for idx, val_tuple in enumerate(zipped_tuples):
            if val_tuple not in unique_elements:
                unique_elements[val_tuple] = []
            unique_elements[val_tuple].append(idx)
        return list(unique_elements.items())
    except TypeError:
        logger = logging.getLogger('pypet.find_unique')
        logger.error('Your parameter entries could not be hashed, '
                     'now I am sorting slowly in O(N**2).')
        unique_elements = []
        for idx, val_tuple in enumerate(zipped_tuples):
            matches = False
            for added_tuple, pos_list in unique_elements:
                matches = True
                for idx2, val in enumerate(added_tuple):
                    if not explored_parameters[idx2]._equal_values(val_tuple[idx2], val):
                        matches = False
                        break
                if matches:
                    pos_list.append(idx)
                    break
            if not matches:
                unique_elements.append((val_tuple, [idx]))
        return unique_elements
Takes a list of explored parameters and finds unique parameter combinations.

    If parameter ranges are hashable operates in O(N), otherwise O(N**2).

    :param explored_parameters:

        List of **explored** parameters

    :return:

        List of tuples, first entry being the parameter values, second entry a list
        containing the run position of the unique combination.