code: def test_pdist():
      raw = np.random.rand(100, 10)
  
      # test 1 chunk
      a = tensor(raw, chunk_size=100)
      dist = distance.pdist(a)
      assert dist.shape == (100 * 99 // 2,)
  
      dist = tile(dist)
      assert len(dist.chunks) == 1
      for c in dist.chunks:
          assert c.shape == (dist.shape[0],)
  
      # test multiple chunks
      a = tensor(raw, chunk_size=15)
      dist = distance.pdist(a, aggregate_size=2)
      assert dist.shape == (100 * 99 // 2,)
  
      dist = tile(dist)
      assert len(dist.chunks) == 2
      for c in dist.chunks:
          assert c.shape == (dist.shape[0] // 2,)
  
      # X cannot be sparse
      raw = sps.csr_matrix(np.zeros((4, 3)))
      a = tensor(raw)
      with pytest.raises(ValueError):
          distance.pdist(a)
  
      # X can only be 2-d
      with pytest.raises(ValueError):
          distance.pdist(np.random.rand(3, 3, 3))
  
      # out type wrong
      with pytest.raises(TypeError):
          distance.pdist(np.random.rand(3, 3), out=2)
  
      # out shape wrong
      with pytest.raises(ValueError):
          distance.pdist(
              np.random.rand(3, 3), out=tensor(np.random.rand(2))
          )
  
      # out dtype wrong
      with pytest.raises(ValueError):
          distance.pdist(
              np.random.rand(3, 3),
              out=tensor(np.random.randint(2, size=(3,))),
          )
  
      # test extra param
      with pytest.raises(TypeError):
          distance.pdist(np.random.rand(3, 3), unknown_kw="unknown_kw")
  
file_path: mars/mars/tensor/spatial/distance/tests/test_distance.py
imports: import numpy
  import pytest
  import scipy.sparse
  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() without return types