code: def test_stack_designs():
      # Test stack_designs function
      N = 10
      X1 = np.ones((N, 1))
      con1 = {"con1": np.array([1])}
      X2 = np.eye(N)
      con2 = {"con2": np.array([1] + [0] * (N - 1))}
      sX, sc = stack_designs((X1, con1), (X2, con2))
      X1_X2 = np.c_[X1, X2]
      exp = (
          X1_X2,
          {"con1": [1] + [0] * N, "con2": [0, 1] + [0] * (N - 1)},
      )
      assert_des_con_equal((sX, sc), exp)
      # Result same when stacking just two designs
      sX, sc = stack2designs(X1, X2, {}, con2)
      # Stacking a design with empty design is OK
      assert_des_con_equal(
          stack2designs([], X2, con1, con2), (X2, con2)
      )
      assert_des_con_equal(
          stack_designs(([], con1), (X2, con2)), (X2, con2)
      )
      assert_des_con_equal(
          stack2designs(X1, [], con1, con2), (X1, con1)
      )
      assert_des_con_equal(
          stack_designs((X1, con1), ([], con2)), (X1, con1)
      )
      # Stacking one design returns output unmodified
      assert_des_con_equal(stack_designs((X1, con1)), (X1, con1))
      # Can stack design without contrasts
      assert_des_con_equal(stack_designs(X1, X2), (X1_X2, {}))
      assert_des_con_equal(
          stack_designs(X1, (X2, con2)),
          (X1_X2, {"con2": [0, 1] + [0] * (N - 1)}),
      )
      assert_des_con_equal(
          stack_designs((X1, con1), X2),
          (X1_X2, {"con1": [1] + [0] * N}),
      )
      # No-contrasts can also be 1-length tuple
      assert_des_con_equal(
          stack_designs((X1,), (X2, con2)),
          (X1_X2, {"con2": [0, 1] + [0] * (N - 1)}),
      )
      assert_des_con_equal(
          stack_designs((X1, con1), (X2,)),
          (X1_X2, {"con1": [1] + [0] * N}),
      )
      # Stack three
      X3 = np.arange(N)[:, None]
      con3 = {"con3": np.array([1])}
      assert_des_con_equal(
          stack_designs((X1, con1), (X2, con2), (X3, con3)),
          (
              np.c_[X1, X2, X3],
              {
                  "con1": [1, 0] + [0] * N,
                  "con2": [0, 1] + [0] * N,
                  "con3": [0] * N + [0, 1],
              },
          ),
      )
  
file_path: nipy/nipy/modalities/fmri/tests/test_design.py
imports: from os.path import dirname
  from os.path import join
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
  from nipy.algorithms.statistics.formula import make_recarray
  from ..design import block_amplitudes, block_design, event_design, openfmri2nipy, stack2designs, stack_designs
  from ..hrf import dglover, glover
  from ..utils import T, blocks, convolve_functions, events, lambdify_t
label_desc: Use image node_id 4 for calling a global function with example usage: test_stack_designs() without return types