code: def test_random_effects():
      subj = F.make_recarray([2, 2, 2, 3, 3], "s")
      subj_factor = F.Factor("s", [2, 3])
  
      c = F.RandomEffects(
          subj_factor.terms, sigma=np.array([[4, 1], [1, 6]])
      )
      C = c.cov(subj)
      assert_almost_equal(
          C,
          [
              [4, 4, 4, 1, 1],
              [4, 4, 4, 1, 1],
              [4, 4, 4, 1, 1],
              [1, 1, 1, 6, 6],
              [1, 1, 1, 6, 6],
          ],
      )
      # Sympy 0.7.0 does not cancel 1.0 * A to A; however, the dot product in the
      # covariance calculation returns floats, which are them multiplied by the
      # terms to give term * 1.0, etc.  We just insert the annoying floating point
      # here for the test, relying on sympy to do the same thing here as in the
      # dot product
      a = sympy.Symbol("a") * 1.0
      b = sympy.Symbol("b") * 1.0
      c = F.RandomEffects(
          subj_factor.terms, sigma=np.array([[a, 0], [0, b]])
      )
      C = c.cov(subj)
      t = np.equal(
          C,
          [
              [a, a, a, 0, 0],
              [a, a, a, 0, 0],
              [a, a, a, 0, 0],
              [0, 0, 0, b, b],
              [0, 0, 0, b, b],
          ],
      )
      assert np.all(t)
  
imports: from warnings import catch_warnings, simplefilter
  import numpy
  import pytest
  import sympy
  from numpy.core.records import fromrecords
  from numpy.testing import assert_almost_equal, assert_array_equal
  from sympy.utilities.lambdify import implemented_function
  from nipy.utils import VisibleDeprecationWarning
  from ..None import formulae
  from ..formulae import Term, terms
label_desc: Use image node_id 6 for calling a global function with example usage: test_random_effects() without return types