# 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 pytest
import numba
import os
import numpy as np
from numpy.testing import assert_array_equal
from umap import distances as dist
    dist_matrix_x = workaround_590_impl(np.abs(spatial_data[:-2]))
    dist_matrix_xy = workaround_590_impl(
        np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
    )

    dist_matrix_x_full = dist.chunked_parallel_special_metric(np.abs(spatial_data[:-2]))
    dist_matrix_xy_full = dist.chunked_parallel_special_metric(
        np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
    )

    assert_array_equal(
        dist_matrix_x_full,
        dist_matrix_x,
        err_msg="Distances don't match for metric hellinger",
    )

    assert_array_equal(
        dist_matrix_xy_full,
        dist_matrix_xy,
        err_msg="Distances don't match for metric hellinger",
    )


@benchmark_only
def test_chunked_parallel_special_metric_implementation_hellinger(
    spatial_data,
    stashed_previous_impl_for_regression_test,
):

    # Base tests that must pass!

# 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/tests/test_chunked_parallel_spatial_metric.py
import pytest
import numba
import os
import numpy as np
from numpy.testing import assert_array_equal
from umap import distances as dist

    dist_matrix_x = workaround_590_impl(np.abs(spatial_data[:-2]))
    dist_matrix_xy = workaround_590_impl(
        np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
    )

    dist_matrix_x_full = dist.chunked_parallel_special_metric(np.abs(spatial_data[:-2]))
    dist_matrix_xy_full = dist.chunked_parallel_special_metric(
        np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
    )

    assert_array_equal(
        dist_matrix_x_full,
        dist_matrix_x,
        err_msg="Distances don't match for metric hellinger",
    )

    assert_array_equal(
        dist_matrix_xy_full,
        dist_matrix_xy,
        err_msg="Distances don't match for metric hellinger",
    )


@benchmark_only
def test_chunked_parallel_special_metric_implementation_hellinger(
    spatial_data,
    stashed_previous_impl_for_regression_test,
):

    # Base tests that must pass!

    dist_matrix_x = dist.chunked_parallel_special_metric(np.abs(spatial_data[:-2]))