code: def test_contrast1():
      x = F.Term("x")
      assert x == x + x
      y = F.Term("y")
      z = F.Term("z")
      f = F.Formula([x, y])
      arr = F.make_recarray([[3, 5, 4], [8, 21, -1], [4, 6, -2]], "xyz")
      D, C = f.design(
          arr,
          contrasts={
              "x": x.formula,
              "diff": F.Formula([x - y]),
              "sum": F.Formula([x + y]),
              "both": F.Formula([x - y, x + y]),
          },
      )
      assert_almost_equal(C["x"], np.array([1, 0]))
      assert_almost_equal(C["diff"], np.array([1, -1]))
      assert_almost_equal(C["sum"], np.array([1, 1]))
      assert_almost_equal(C["both"], np.array([[1, -1], [1, 1]]))
  
      f = F.Formula([x, y, z])
      arr = F.make_recarray([[3, 5, 4], [8, 21, -1], [4, 6, -2]], "xyz")
      D, C = f.design(
          arr,
          contrasts={
              "x": x.formula,
              "diff": F.Formula([x - y]),
              "sum": F.Formula([x + y]),
              "both": F.Formula([x - y, x + y]),
          },
      )
      assert_almost_equal(C["x"], np.array([1, 0, 0]))
      assert_almost_equal(C["diff"], np.array([1, -1, 0]))
      assert_almost_equal(C["sum"], np.array([1, 1, 0]))
      assert_almost_equal(C["both"], np.array([[1, -1, 0], [1, 1, 0]]))
  
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 4 for calling a global function with example usage: test_contrast1() without return types