code: def test_squareform_execution(setup):
      from scipy.spatial.distance import (
          pdist as sp_pdist,
          squareform as sp_squareform,
      )
  
      raw_a = np.random.rand(80, 10)
      raw_pdsit = sp_pdist(raw_a)
      raw_square = sp_squareform(raw_pdsit)
  
      # tomatrix, test 1 chunk
      vec = tensor(raw_pdsit, chunk_size=raw_pdsit.shape[0])
      mat = distance.squareform(vec, chunk_size=100)
      result = mat.execute().fetch()
      np.testing.assert_array_equal(result, raw_square)
  
      # tomatrix, test more than 1 chunk
      vec = tensor(raw_pdsit, chunk_size=33)
      assert len(tile(vec).chunks) > 1
      mat = distance.squareform(vec, chunk_size=34)
      result = mat.execute().fetch()
      np.testing.assert_array_equal(result, raw_square)
  
      # tovec, test 1 chunk
      mat = tensor(raw_square)
      vec = distance.squareform(mat, chunk_size=raw_pdsit.shape[0])
      assert len(tile(mat).chunks) == 1
      assert len(tile(vec).chunks) == 1
      result = vec.execute().fetch()
      np.testing.assert_array_equal(result, raw_pdsit)
  
      # tovec, test more than 1 chunk
      mat = tensor(raw_square, chunk_size=31)
      vec = distance.squareform(mat, chunk_size=40)
      assert len(tile(vec).chunks) > 1
      result = vec.execute().fetch()
      np.testing.assert_array_equal(result, raw_pdsit)
  
      # test checks
      # generate non-symmetric matrix
      non_sym_arr = np.random.RandomState(0).rand(10, 10)
  
      # 1 chunk
      mat = tensor(non_sym_arr)
      vec = distance.squareform(mat, checks=True, chunk_size=100)
      with pytest.raises(ValueError):
          _ = vec.execute().fetch()
      # force checks=False
      vec = distance.squareform(mat, checks=False, chunk_size=100)
      _ = vec.execute().fetch()
  
      # more than 1 chunk
      mat = tensor(non_sym_arr, chunk_size=6)
      vec = distance.squareform(mat, checks=True, chunk_size=8)
      assert len(tile(vec).chunks) > 1
      with pytest.raises(ValueError):
          _ = vec.execute().fetch()
      # force checks=False
      vec = distance.squareform(mat, checks=False, chunk_size=100)
      _ = vec.execute().fetch()
  
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 3 for calling a global function with example usage: test_squareform_execution(setup) without return types