code: def test_quantile():
      raw = np.random.rand(100)
      q = np.random.rand(10)
  
      quantile_dtypes = [np.float32, np.int64]
      if np_version < Version("1.25"):
          quantile_dtypes.extend([np.complex128])
  
      for dtype in quantile_dtypes:
          raw2 = raw.astype(dtype)
          a = tensor(raw2, chunk_size=100)
  
          b = quantile(a, q, overwrite_input=True)
          assert b.shape == (10,)
          assert b.dtype == np.quantile(raw2, q).dtype
  
          b = tile(b)
          assert len(b.chunks) == 1
  
      raw = np.random.rand(20, 10)
      q = np.random.rand(10)
  
      for dtype in quantile_dtypes:
          for axis in (None, 0, 1, [0, 1]):
              for interpolation in INTERPOLATION_TYPES:
                  for keepdims in [True, False]:
                      raw2 = raw.astype(dtype)
                      a = tensor(raw2, chunk_size=(8, 6))
  
                      b = quantile(
                          a,
                          q,
                          axis=axis,
                          interpolation=interpolation,
                          keepdims=keepdims,
                      )
                      expected = np.quantile(
                          raw2,
                          q,
                          axis=axis,
                          interpolation=interpolation,
                          keepdims=keepdims,
                      )
                      assert b.shape == expected.shape
                      assert b.dtype == expected.dtype
  
      a = tensor(raw, chunk_size=10)
      b = quantile(a, q)
  
      b = tile(b)
      assert b.shape == (10,)
  
      b = quantile(a, 0.3)
      assert b.ndim == 0
  
      raw2 = np.random.rand(3, 4, 5)
      a2 = tensor(raw2, chunk_size=3)
      b2 = quantile(a2, q, axis=(0, 2))
      expected = np.quantile(raw2, q, axis=(0, 2))
      assert b2.shape == expected.shape
  
      b2 = tile(b2)
      assert b2.shape == expected.shape
  
      # q has to be 1-d
      with pytest.raises(ValueError):
          quantile(a, q.reshape(5, 2))
  
      # wrong out type
      with pytest.raises(TypeError):
          quantile(a, q, out=2)
  
      # wrong q
      with pytest.raises(ValueError):
          q2 = q.copy()
          q2[0] = 1.1
          quantile(a, q2)
  
      # wrong q, with size < 10
      with pytest.raises(ValueError):
          q2 = np.random.rand(5)
          q2[0] = 1.1
          quantile(a, q2)
  
      # wrong interpolation
      with pytest.raises(ValueError):
          quantile(a, q, interpolation="unknown")
  
file_path: mars/mars/tensor/statistics/tests/test_statistics.py
imports: import numpy
  import pytest
  from ....core import tile
  from ....lib.version import Version
  from ...datasource import tensor, array
  from ..None import digitize, histogram_bin_edges, quantile, percentile
  from ..quantile import INTERPOLATION_TYPES
label_desc: Use image node_id 3 for calling a global function with example usage: test_quantile() without return types