Package geometry :: Package manifolds :: Package tests :: Module matrix_groups_tests
[hide private]
[frames] | no frames]

Source Code for Module geometry.manifolds.tests.matrix_groups_tests

 1  from geometry import MatrixLieGroup 
 2  from nose.plugins.attrib import attr 
 3  from geometry.manifolds.tests.manifold_tests import manifolds_to_check 
4 5 6 -def check_matrix_group_1(M):
7 for m in M.interesting_points(): 8 M.belongs(m) 9 v = M.algebra_from_group(m) 10 M.algebra.belongs(v) 11 m2 = M.group_from_algebra(v) 12 M.assert_close(m, m2)
13 #printm('Checked %s' % M, m)
14 15 16 -def check_matrix_group_2(M):
17 algebra = M.get_algebra() 18 for a in algebra.interesting_points(): 19 #printm('Checked %s' % M, a) 20 M.algebra.belongs(a) 21 g = M.group_from_algebra(a) 22 M.belongs(g)
23
24 25 -def check_matrix_group_vector_isomorphism(M):
26 algebra = M.get_algebra() 27 expected = (algebra.get_dimension(),) 28 for p in M.interesting_points(): 29 M.belongs(p) 30 # convert point to algebra 31 a = M.algebra_from_group(p) 32 algebra.belongs(a) 33 # convert algebra to vector 34 v = algebra.vector_from_algebra(a) 35 36 if v.shape != expected: 37 raise ValueError('%s: expected %s, got %s ' % 38 (algebra, expected, v.shape)) 39 40 # Now back to algebra 41 a2 = algebra.algebra_from_vector(v) 42 algebra.belongs(a2) 43 algebra.assert_close(a, a2)
44
45 46 -def check_enough_points_for_algebra(M):
47 algebra = M.get_algebra() 48 points = list(algebra.interesting_points()) 49 if not points: 50 raise ValueError('No test points for algebra of %s.' % M)
51
52 53 @attr('manifolds') 54 -def test_group_algebra():
55 ftests = [ 56 check_matrix_group_1, 57 check_matrix_group_2, 58 check_matrix_group_vector_isomorphism, 59 check_enough_points_for_algebra 60 ] 61 for a in manifolds_to_check(): 62 if isinstance(a, MatrixLieGroup): 63 for f in ftests: 64 yield f, a
65