code: def test_array_correlation():
      import numpy as np
      from brainiak.utils.utils import array_correlation
      from scipy.stats import pearsonr
  
      # Minimal array datasets
      n_TRs = 30
      n_voxels = 2
      x, y = (
          np.random.randn(n_TRs, n_voxels),
          np.random.randn(n_TRs, n_voxels),
      )
  
      # Perform the correlation
      r = array_correlation(x, y)
  
      # Check there are the right number of voxels in the output
      assert r.shape == (n_voxels,)
  
      # Check that this (roughly) matches corrcoef
      assert np.allclose(r, np.corrcoef(x.T, y.T)[[0, 1], [2, 3]])
  
      # Check that this (roughly) matches pearsonr
      assert np.allclose(
          r,
          np.array(
              [
                  pearsonr(x[:, 0], y[:, 0])[0],
                  pearsonr(x[:, 1], y[:, 1])[0],
              ]
          ),
      )
  
      # Try axis argument
      assert np.allclose(
          array_correlation(x, y, axis=0),
          array_correlation(x.T, y.T, axis=1),
      )
  
      # Trigger shape mismatch error
      with pytest.raises(ValueError):
          array_correlation(x, y[:, 0])
  
      with pytest.raises(ValueError):
          array_correlation(x, y[:-1])
  
      # Feed in lists
      _ = array_correlation(x.tolist(), y)
      _ = array_correlation(x, y.tolist())
      _ = array_correlation(x.tolist(), y.tolist())
  
      # Check 1D array input
      x, y = (np.random.randn(n_TRs), np.random.randn(n_TRs))
  
      assert type(array_correlation(x, y)) == np.float64
      assert np.isclose(array_correlation(x, y), pearsonr(x, y)[0])
  
      # 1D list inputs
      _ = array_correlation(x.tolist(), y)
      _ = array_correlation(x, y.tolist())
      _ = array_correlation(x.tolist(), y.tolist())
  
      # Check integer inputs
      x, y = (
          np.random.randint(0, 9, (n_TRs, n_voxels)),
          np.random.randint(0, 9, (n_TRs, n_voxels)),
      )
      _ = array_correlation(x, y)
  
file_path: brainiak/tests/utils/test_utils.py
imports: import pytest
label_desc: Use image node_id 11 for calling a global function with example usage: test_array_correlation() without return types