def Renormalize(similarity,
                metric = "carbo",
                customrange = None,
):
    """
    Renormalizes a similarity metric to the range [0:1]
    :param similarity: Similarity score.
    :param mode: (optional) Mode of similarity score
    :param customrange: (optional) Custom range of similarity score, overrides mode parameter. Tuple or list of two values.
    :return: Renormalized similarity score
    """
    if customrange != None:
        similarity=(similarity-customrange[0])/(customrange[1]-customrange[0])
    elif metric=="carbo":
        similarity=(similarity+1)/2
    elif metric=="tanimoto":
        similarity=(similarity+0.3)/1.3
    else:
        raise ValueError("Unknown metric.")
    return similarity