code: 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])
      )
      dist_matrix_xy = dist.chunked_parallel_special_metric(
          np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
      )
      test_matrix = np.array(
          [
              [
                  dist.hellinger_grad(
                      np.abs(spatial_data[i]), np.abs(spatial_data[j])
                  )[0]
                  for j in range(spatial_data.shape[0] - 2)
              ]
              for i in range(spatial_data.shape[0] - 2)
          ]
      ).astype(np.float32)
  
      assert_array_equal(
          test_matrix,
          dist_matrix_x,
          err_msg="Distances don't match for metric hellinger",
      )
  
      assert_array_equal(
          test_matrix,
          dist_matrix_xy,
          err_msg="Distances don't match for metric hellinger",
      )
  
      # Test to compare chunked_parallel different implementations
      dist_x_stashed = stashed_previous_impl_for_regression_test(
          np.abs(spatial_data[:-2])
      )
      dist_xy_stashed = stashed_previous_impl_for_regression_test(
          np.abs(spatial_data[:-2]), np.abs(spatial_data[:-2])
      )
  
      assert_array_equal(
          dist_xy_stashed,
          dist_matrix_xy,
          err_msg="Distances don't match between stashed and current chunked_parallel implementations with X and Y!",
      )
  
      assert_array_equal(
          dist_x_stashed,
          dist_matrix_x,
          err_msg="Distances don't match between stashed and current chunked_parallel implementations with X only!",
      )
  
      # test hellinger on different X and Y Pair
      spatial_data_two = np.random.randn(10, 20)
      dist_stashed_diff_pair = (
          stashed_previous_impl_for_regression_test(
              np.abs(spatial_data[:-2]), spatial_data_two
          )
      )
      dist_chunked_diff_pair = dist.chunked_parallel_special_metric(
          np.abs(spatial_data[:-2]), spatial_data_two
      )
  
      assert_array_equal(
          dist_stashed_diff_pair,
          dist_chunked_diff_pair,
          err_msg="Distances don't match between stashed and current chunked_parallel implementations",
      )
  
file_path: umap/umap/tests/test_chunked_parallel_spatial_metric.py
imports: import pytest
  import numba
  import os
  import numpy
  from numpy.testing import assert_array_equal
  from umap import distances
label_desc: Use image node_id 5 for calling a global function with example usage: test_chunked_parallel_special_metric_implementation_hellinger(spatial_data, stashed_previous_impl_for_regression_test) without return types