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

Source Code for Module geometry.manifolds.tests.embedding_test

 1  from geometry.manifolds import (SO3, SO2, R1, R2, R3, SE2, SE3, S2, S1, T1, T2, 
 2      T3, so2, so3, se2, se3, Tran3, Tran2, Tran1, tran2, tran1, tran3) 
 3  from nose.plugins.attrib import attr 
4 5 6 -def check_embed_relation_cond(A, B):
7 check_embed_relation_cond.description = 'Checking %s < %s' % (A, B) 8 msg = None 9 if not A.embeddable_in(B): 10 msg = '%s is not embeddable in %s' % (A, B) 11 if not B.can_represent(A): 12 msg = '%s cannot represent %s' % (B, A) 13 if msg: 14 raise Exception('%s;\n %s: %s\n %s: %s' % 15 (msg, A, A.relations_descriptions(), 16 B, B.relations_descriptions()))
17
18 19 -def check_embed_relation(A, B):
20 21 check_embed_relation_cond(A, B) 22 23 points = list(A.interesting_points()) 24 if not points: 25 msg = ('Cannot test because manifold %s does ' 26 'not have interesting points' % A) 27 raise Exception(msg) 28 29 for a1 in points: 30 A.belongs(a1) 31 b = A.embed_in(B, a1) 32 B.belongs(b) 33 a2 = A.project_from(B, b) 34 A.belongs(a2) 35 a3 = B.project_to(A, b) 36 A.belongs(a3) 37 A.assert_close(a1, a2) 38 A.assert_close(a1, a3)
39
40 41 @attr('embed') 42 -def test_embed_relations():
43 couples = [] 44 45 def add(A, B): 46 couples.append((A, B))
47 48 add(R1, R2) 49 add(R2, R3) 50 add(R1, R3) 51 52 add(SO2, SO3) 53 add(SO2, SE3) 54 55 add(SO2, SE2) 56 add(SO3, SE3) 57 add(so3, se3) 58 add(so2, se2) 59 add(so2, se3) 60 61 add(S1, S2) 62 63 add(R1, SE2) 64 add(R2, SE2) 65 add(R1, SE3) 66 add(R2, SE3) 67 add(R3, SE3) 68 add(Tran1, SE2) 69 add(Tran2, SE2) 70 add(Tran1, SE3) 71 add(Tran2, SE3) 72 add(Tran3, SE3) 73 74 add(T1, T2) 75 add(T2, T3) 76 add(T1, T3) 77 78 add(T1, R1) 79 add(T2, R2) 80 add(T3, R3) 81 82 add(T3, SE3) 83 84 add(S1, SE3) 85 add(S2, SE3) 86 87 add(tran1, se3) 88 add(tran2, se3) 89 add(tran3, se3) 90 91 add(T1, S1) 92 93 for A, B in couples: 94 check_embed_relation(A, B) 95