# Path: umap/distances.py
# def sign(a):
# def euclidean(x, y):
# def euclidean_grad(x, y):
# def standardised_euclidean(x, y, sigma=_mock_ones):
# def standardised_euclidean_grad(x, y, sigma=_mock_ones):
# def manhattan(x, y):
# def manhattan_grad(x, y):
# def chebyshev(x, y):
# def chebyshev_grad(x, y):
# def minkowski(x, y, p=2):
# def minkowski_grad(x, y, p=2):
# def poincare(u, v):
# def hyperboloid_grad(x, y):
# def weighted_minkowski(x, y, w=_mock_ones, p=2):
# def weighted_minkowski_grad(x, y, w=_mock_ones, p=2):
# def mahalanobis(x, y, vinv=_mock_identity):
# def mahalanobis_grad(x, y, vinv=_mock_identity):
# def hamming(x, y):
# def canberra(x, y):
# def canberra_grad(x, y):
# def bray_curtis(x, y):
# def bray_curtis_grad(x, y):
# def jaccard(x, y):
# def matching(x, y):
# def dice(x, y):
# def kulsinski(x, y):
# def rogers_tanimoto(x, y):
# def russellrao(x, y):
# def sokal_michener(x, y):
# def sokal_sneath(x, y):
# def haversine(x, y):
# def haversine_grad(x, y):
# def yule(x, y):
# def cosine(x, y):
# def cosine_grad(x, y):
# def correlation(x, y):
# def hellinger(x, y):
# def hellinger_grad(x, y):
# def approx_log_Gamma(x):
# def log_beta(x, y):
# def log_single_beta(x):
# def ll_dirichlet(data1, data2):
# def symmetric_kl(x, y, z=1e-11):  # pragma: no cover
# def symmetric_kl_grad(x, y, z=1e-11):  # pragma: no cover
# def correlation_grad(x, y):
# def sinkhorn_distance(
#     x, y, M=_mock_identity, cost=_mock_cost, maxiter=64
# ):  # pragma: no cover
# def spherical_gaussian_energy_grad(x, y):  # pragma: no cover
# def diagonal_gaussian_energy_grad(x, y):  # pragma: no cover
# def gaussian_energy_grad(x, y):  # pragma: no cover
# def spherical_gaussian_grad(x, y):  # pragma: no cover
# def get_discrete_params(data, metric):
# def categorical_distance(x, y):
# def hierarchical_categorical_distance(x, y, cat_hierarchy=[{}]):
# def ordinal_distance(x, y, support_size=1.0):
# def count_distance(x, y, poisson_lambda=1.0, normalisation=1.0):
# def levenshtein(x, y, normalisation=1.0, max_distance=20):
# def parallel_special_metric(X, Y=None, metric=hellinger):
# def chunked_parallel_special_metric(X, Y=None, metric=hellinger, chunk_size=16):
# def pairwise_special_metric(X, Y=None, metric="hellinger", kwds=None):
#         def _partial_metric(_X, _Y=None):
#     B = s * t
#         B = 1.0 + 1e-8
# DISCRETE_METRICS = (
#     "categorical",
#     "hierarchical_categorical",
#     "ordinal",
#     "count",
#     "string",
# )
# SPECIAL_METRICS = (
#     "hellinger",
#     "ll_dirichlet",
#     "symmetric_kl",
#     "poincare",
#     hellinger,
#     ll_dirichlet,
#     symmetric_kl,
#     poincare,
# )


import numpy as np
import numba
from sklearn.neighbors import KDTree
from umap.distances import named_distances
                for k in range(j + 1, max_k + 1):
                    if rank > k:
                        trustworthiness[k] += rank - k

        for k in range(1, max_k + 1):
            trustworthiness[k] = 1.0 - trustworthiness[k] * (
                2.0 / (n_samples * k * (2.0 * n_samples - 3.0 * k - 1.0))
            )

        trustworthiness[0] = 1.0

        return trustworthiness

    return trustworthiness_vector_lowmem


def trustworthiness_vector(
    source, embedding, max_k, metric="euclidean"
):  # pragma: no cover
    tree = KDTree(embedding, metric=metric)
    indices_embedded = tree.query(embedding, k=max_k, return_distance=False)
    # Drop the actual point itself
    indices_embedded = indices_embedded[:, 1:]

    dist = named_distances[metric]

    vec_calculator = make_trustworthiness_calculator(dist)

    result = vec_calculator(source, indices_embedded, max_k)


# Path: umap/distances.py
# def sign(a):
# def euclidean(x, y):
# def euclidean_grad(x, y):
# def standardised_euclidean(x, y, sigma=_mock_ones):
# def standardised_euclidean_grad(x, y, sigma=_mock_ones):
# def manhattan(x, y):
# def manhattan_grad(x, y):
# def chebyshev(x, y):
# def chebyshev_grad(x, y):
# def minkowski(x, y, p=2):
# def minkowski_grad(x, y, p=2):
# def poincare(u, v):
# def hyperboloid_grad(x, y):
# def weighted_minkowski(x, y, w=_mock_ones, p=2):
# def weighted_minkowski_grad(x, y, w=_mock_ones, p=2):
# def mahalanobis(x, y, vinv=_mock_identity):
# def mahalanobis_grad(x, y, vinv=_mock_identity):
# def hamming(x, y):
# def canberra(x, y):
# def canberra_grad(x, y):
# def bray_curtis(x, y):
# def bray_curtis_grad(x, y):
# def jaccard(x, y):
# def matching(x, y):
# def dice(x, y):
# def kulsinski(x, y):
# def rogers_tanimoto(x, y):
# def russellrao(x, y):
# def sokal_michener(x, y):
# def sokal_sneath(x, y):
# def haversine(x, y):
# def haversine_grad(x, y):
# def yule(x, y):
# def cosine(x, y):
# def cosine_grad(x, y):
# def correlation(x, y):
# def hellinger(x, y):
# def hellinger_grad(x, y):
# def approx_log_Gamma(x):
# def log_beta(x, y):
# def log_single_beta(x):
# def ll_dirichlet(data1, data2):
# def symmetric_kl(x, y, z=1e-11):  # pragma: no cover
# def symmetric_kl_grad(x, y, z=1e-11):  # pragma: no cover
# def correlation_grad(x, y):
# def sinkhorn_distance(
#     x, y, M=_mock_identity, cost=_mock_cost, maxiter=64
# ):  # pragma: no cover
# def spherical_gaussian_energy_grad(x, y):  # pragma: no cover
# def diagonal_gaussian_energy_grad(x, y):  # pragma: no cover
# def gaussian_energy_grad(x, y):  # pragma: no cover
# def spherical_gaussian_grad(x, y):  # pragma: no cover
# def get_discrete_params(data, metric):
# def categorical_distance(x, y):
# def hierarchical_categorical_distance(x, y, cat_hierarchy=[{}]):
# def ordinal_distance(x, y, support_size=1.0):
# def count_distance(x, y, poisson_lambda=1.0, normalisation=1.0):
# def levenshtein(x, y, normalisation=1.0, max_distance=20):
# def parallel_special_metric(X, Y=None, metric=hellinger):
# def chunked_parallel_special_metric(X, Y=None, metric=hellinger, chunk_size=16):
# def pairwise_special_metric(X, Y=None, metric="hellinger", kwds=None):
#         def _partial_metric(_X, _Y=None):
#     B = s * t
#         B = 1.0 + 1e-8
# DISCRETE_METRICS = (
#     "categorical",
#     "hierarchical_categorical",
#     "ordinal",
#     "count",
#     "string",
# )
# SPECIAL_METRICS = (
#     "hellinger",
#     "ll_dirichlet",
#     "symmetric_kl",
#     "poincare",
#     hellinger,
#     ll_dirichlet,
#     symmetric_kl,
#     poincare,
# )


# Path: umap/validation.py
import numpy as np
import numba
from sklearn.neighbors import KDTree
from umap.distances import named_distances

                for k in range(j + 1, max_k + 1):
                    if rank > k:
                        trustworthiness[k] += rank - k

        for k in range(1, max_k + 1):
            trustworthiness[k] = 1.0 - trustworthiness[k] * (
                2.0 / (n_samples * k * (2.0 * n_samples - 3.0 * k - 1.0))
            )

        trustworthiness[0] = 1.0

        return trustworthiness

    return trustworthiness_vector_lowmem


def trustworthiness_vector(
    source, embedding, max_k, metric="euclidean"
):  # pragma: no cover
    tree = KDTree(embedding, metric=metric)
    indices_embedded = tree.query(embedding, k=max_k, return_distance=False)
    # Drop the actual point itself
    indices_embedded = indices_embedded[:, 1:]

    dist = named_distances[metric]

    vec_calculator = make_trustworthiness_calculator(dist)

    result = vec_calculator(source, indices_embedded, max_k)


    return result