(names, proposed, equal_numbers=True)
Returns unique names for variables

    Proposed is a list of names (or a string with a single name). If any name
    already appears in `names`, the function appends an index in parentheses,
    which is one higher than the highest index at these variables. Also, if
    `names` contains any of the names with index in parentheses, this counts
    as an occurence of the name. For instance, if `names` does not contain
    `x` but it contains `x (3)`, `get_unique_names` will replace `x` with
    `x (4)`.

    If argument `names` is domain, the method observes all variables and metas.

    Function returns a string if `proposed` is a string, and a list if it's a
    list.

    The method is used in widgets like MDS, which adds two variables (`x` and
    `y`). It is desired that they have the same index. In case when
    equal_numbers=True, if `x`, `x (1)` and `x (2)` and `y` (but no other
    `y`'s already exist in the domain, MDS should append `x (3)` and `y (3)`,
    not `x (3)` and y (1)`.

    Args:
        names (Domain or list of str): used names
        proposed (str or list of str): proposed name
        equal_numbers (bool): Add same number to all proposed names

    Return:
        str or list of str
Returns unique names for variables
Returns unique names for variables
def get_unique_names(names, proposed, equal_numbers=True):
    """
    Returns unique names for variables

    Proposed is a list of names (or a string with a single name). If any name
    already appears in `names`, the function appends an index in parentheses,
    which is one higher than the highest index at these variables. Also, if
    `names` contains any of the names with index in parentheses, this counts
    as an occurence of the name. For instance, if `names` does not contain
    `x` but it contains `x (3)`, `get_unique_names` will replace `x` with
    `x (4)`.

    If argument `names` is domain, the method observes all variables and metas.

    Function returns a string if `proposed` is a string, and a list if it's a
    list.

    The method is used in widgets like MDS, which adds two variables (`x` and
    `y`). It is desired that they have the same index. In case when
    equal_numbers=True, if `x`, `x (1)` and `x (2)` and `y` (but no other
    `y`'s already exist in the domain, MDS should append `x (3)` and `y (3)`,
    not `x (3)` and y (1)`.

    Args:
        names (Domain or list of str): used names
        proposed (str or list of str): proposed name
        equal_numbers (bool): Add same number to all proposed names

    Return:
        str or list of str
    """
    # prevent cyclic import: pylint: disable=import-outside-toplevel
    from Orange.data import Domain
    if isinstance(names, Domain):
        names = [var.name for var in chain(names.variables, names.metas)]
    if isinstance(proposed, str):
        return get_unique_names(names, [proposed])[0]
    indices = {name: get_indices(names, name) for name in proposed}
    indices = {name: max(ind) + 1 for name, ind in indices.items() if ind}
    if not (set(proposed) & set(names) or indices):
        return proposed
    if equal_numbers:
        max_index = max(indices.values())
        return [f"{name} ({max_index})" for name in proposed]
    else:
        return [f"{name} ({indices[name]})" if name in indices else name
                for name in proposed]
def get_unique_names ( names , proposed , equal_numbers = True ) : # prevent cyclic import: pylint: disable=import-outside-toplevel from Orange . data import Domain if isinstance ( names , Domain ) : names = [ var . name for var in chain ( names . variables , names . metas ) ] if isinstance ( proposed , str ) : return get_unique_names ( names , [ proposed ] ) [ 0 ] indices = { name : get_indices ( names , name ) for name in proposed } indices = { name : max ( ind ) + 1 for name , ind in indices . items ( ) if ind } if not ( set ( proposed ) & set ( names ) or indices ) : return proposed if equal_numbers : max_index = max ( indices . values ( ) ) return [ f"{name} ({max_index})" for name in proposed ] else : return [ f"{name} ({indices[name]})" if name in indices else name for name in proposed ]