code: def test_subgrid_affine():
      # Takes an affine and a series of slices, creates affine from slices,
      # returns dot(affine, affine_from_slices)
      slices = [slice(2, 11, 4), slice(3, 11, 5), slice(4, 11, 6)]
      assert_array_equal(
          subgrid_affine(np.eye(4), slices),
          [[4, 0, 0, 2], [0, 5, 0, 3], [0, 0, 6, 4], [0, 0, 0, 1]],
      )
      assert_array_equal(
          subgrid_affine(np.diag([2, 3, 4, 1]), slices),
          [[8, 0, 0, 4], [0, 15, 0, 9], [0, 0, 24, 16], [0, 0, 0, 1]],
      )
      # Raises error for non-integer slice arguments
      slices[0] = slice(2.1, 11, 4)
      pytest.raises(ValueError, subgrid_affine, np.eye(4), slices)
  
file_path: nipy/nipy/algorithms/registration/tests/test_affine.py
imports: import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ....testing import assert_almost_equal
  from ..affine import Affine, Affine2D, Rigid, Rigid2D, Similarity, Similarity2D, rotation_mat2vec, slices2aff, subgrid_affine
label_desc: Use image node_id 8 for calling a global function with example usage: test_subgrid_affine() without return types