code: def test_cdist_execution(setup):
      from scipy.spatial.distance import cdist as sp_cdist
  
      raw_a = np.random.rand(100, 10)
      raw_b = np.random.rand(89, 10)
  
      # test 1 chunk
      xa = tensor(raw_a, chunk_size=100)
      xb = tensor(raw_b, chunk_size=100)
  
      dist = distance.cdist(xa, xb)
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b)
      np.testing.assert_array_equal(result, expected)
  
      dist = distance.cdist(xa, xb, metric="hamming")
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b, metric="hamming")
      np.testing.assert_array_equal(result, expected)
  
      f = lambda u, v: np.sqrt(((u - v) ** 2).sum())
      dist = distance.cdist(xa, xb, metric=f)
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b, metric=f)
      np.testing.assert_array_equal(result, expected)
  
      # test more than 1 chunk
      xa = tensor(raw_a, chunk_size=12)
      xb = tensor(raw_b, chunk_size=13)
  
      dist = distance.cdist(xa, xb)
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b)
      np.testing.assert_array_equal(result, expected)
  
      dist = distance.cdist(xa, xb, metric="hamming")
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b, metric="hamming")
      np.testing.assert_array_equal(result, expected)
  
      f = lambda u, v: np.sqrt(((u - v) ** 2).sum())
      dist = distance.cdist(xa, xb, metric=f)
      result = dist.execute().fetch()
      expected = sp_cdist(raw_a, raw_b, metric=f)
      np.testing.assert_array_equal(result, expected)
  
      for xa, xb in [
          (tensor(raw_a), tensor(raw_b)),
          (tensor(raw_a, chunk_size=12), tensor(raw_b, chunk_size=13)),
      ]:
          # test w
          weight = np.random.rand(10)
          w = tensor(weight, chunk_size=7)
          dist = distance.cdist(xa, xb, metric="wminkowski", p=3, w=w)
          result = dist.execute().fetch()
          expected = sp_cdist(
              raw_a, raw_b, metric="minkowski", p=3, w=weight
          )
          np.testing.assert_array_equal(result, expected)
  
          # test V
          v = np.random.rand(10)
          V = tensor(v, chunk_size=7)
          dist = distance.cdist(xa, xb, metric="seuclidean", V=V)
          result = dist.execute().fetch()
          expected = sp_cdist(raw_a, raw_b, metric="seuclidean", V=v)
          np.testing.assert_array_equal(result, expected)
  
          # test VI
          vi = np.random.rand(10, 10)
          VI = tensor(vi, chunk_size=8)
          dist = distance.cdist(xa, xb, metric="mahalanobis", VI=VI)
          result = dist.execute().fetch()
          expected = sp_cdist(raw_a, raw_b, metric="mahalanobis", VI=vi)
          np.testing.assert_array_equal(result, expected)
  
file_path: mars/mars/tensor/spatial/distance/tests/test_distance_execution.py
imports: import numpy
  import pytest
  from .....core import tile
  from ....datasource import tensor
  from ...None import distance
label_desc: Use image node_id 2 for calling a global function with example usage: test_cdist_execution(setup) without return types