def _check_similarity(similarity, length):
    """Check if measures are similarities or dissimilarities"""
    if isinstance(similarity, bool):
        similarity_list = [similarity] * length
    elif isinstance(similarity, list) and all(isinstance(s, bool) for s in similarity) and len(similarity) == length:
        similarity_list = similarity
    else:
        raise ValueError("the similarity parameter should be a boolean or a list of booleans indicating "
                         "if measures are similarities or dissimilarities, '{}' (type '{}') "
                         "was passed.".format(similarity, type(similarity)))
    return similarity_list