code: def test_pdist_execution(setup):
      from scipy.spatial.distance import pdist as sp_pdist
  
      raw = np.random.rand(100, 10)
  
      # test 1 chunk
      x = tensor(raw, chunk_size=100)
  
      dist = distance.pdist(x)
      result = dist.execute().fetch()
      expected = sp_pdist(raw)
      np.testing.assert_array_equal(result, expected)
  
      dist = distance.pdist(x, metric="hamming")
      result = dist.execute().fetch()
      expected = sp_pdist(raw, metric="hamming")
      np.testing.assert_array_equal(result, expected)
  
      f = lambda u, v: np.sqrt(((u - v) ** 2).sum())
      dist = distance.pdist(x, metric=f)
      result = dist.execute().fetch()
      expected = sp_pdist(raw, metric=f)
      np.testing.assert_array_equal(result, expected)
  
      # test more than 1 chunk
      x = tensor(raw, chunk_size=12)
  
      dist = distance.pdist(x)
      tdist = tile(dist)
      assert len(tdist.chunks) == 1
      result = dist.execute().fetch()
      expected = sp_pdist(raw)
      np.testing.assert_array_equal(result, expected)
  
      dist = distance.pdist(x, aggregate_size=3)
      tdist = tile(dist)
      assert len(tdist.chunks) == 3
      result = dist.execute().fetch()
      expected = sp_pdist(raw)
      np.testing.assert_array_equal(result, expected)
  
      dist = distance.pdist(x, metric="hamming", aggregate_size=2)
      tdist = tile(dist)
      assert len(tdist.chunks) == 2
      result = dist.execute().fetch()
      expected = sp_pdist(raw, metric="hamming")
      np.testing.assert_array_equal(result, expected)
  
      f = lambda u, v: np.sqrt(((u - v) ** 2).sum())
      dist = distance.pdist(x, metric=f, aggregate_size=2)
      result = dist.execute().fetch()
      expected = sp_pdist(raw, metric=f)
      np.testing.assert_array_equal(result, expected)
  
      for x in [tensor(raw), tensor(raw, chunk_size=12)]:
          # test w
          weight = np.random.rand(10)
          w = tensor(weight, chunk_size=7)
          dist = distance.pdist(x, metric="wminkowski", p=3, w=w)
          result = dist.execute().fetch()
          expected = sp_pdist(raw, 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.pdist(x, metric="seuclidean", V=V)
          result = dist.execute().fetch()
          expected = sp_pdist(raw, 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.pdist(x, metric="mahalanobis", VI=VI)
          result = dist.execute().fetch()
          expected = sp_pdist(raw, 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 1 for calling a global function with example usage: test_pdist_execution(setup) without return types