code: def test_affine_types():
      pts = np.random.normal(size=(10, 3))
      for klass, n_params in (
          (Affine, 12),
          (Affine2D, 6),
          (Rigid, 6),
          (Rigid2D, 3),
          (Similarity, 7),
          (Similarity2D, 4),
      ):
          obj = klass()
          assert_array_equal(obj.param, np.zeros((n_params,)))
          obj.param = np.ones((n_params,))
          assert_array_equal(obj.param, np.ones((n_params,)))
          # Check that round trip works
          orig_aff = obj.as_affine()
          obj2 = klass(orig_aff)
          assert_array_almost_equal(obj2.as_affine(), orig_aff)
          # Check inverse
          inv_obj = obj.inv()
          # Check points transform and invert
          pts_dash = obj.apply(pts)
          assert_array_almost_equal(pts, inv_obj.apply(pts_dash))
          # Check composition with inverse gives identity
          with_inv = inv_obj.compose(obj)
          assert_array_almost_equal(with_inv.as_affine(), np.eye(4))
          # Just check that str works without error
          s = str(obj)
          # Check default parameter input
          obj = klass(np.zeros((12,)))
          assert_array_equal(obj.param, np.zeros((n_params,)))
          obj = klass(list(np.zeros((12,))))
          assert_array_equal(obj.param, np.zeros((n_params,)))
  
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 5 for calling a global function with example usage: test_affine_types() without return types