11import unittest
2+
23from bvh import Bvh , BvhNode
34
45
@@ -16,12 +17,16 @@ def test_empty_root(self):
1617 def test_tree (self ):
1718 with open ('tests/test_freebvh.bvh' ) as f :
1819 mocap = Bvh (f .read ())
19- self .assertEqual ([str (item ) for item in mocap .root ], ['HIERARCHY' , 'ROOT mixamorig:Hips' , 'MOTION' , 'Frames: 69' , 'Frame Time: 0.0333333' ])
20+ self .assertEqual ([str (item ) for item in mocap .root ],
21+ ['HIERARCHY' , 'ROOT mixamorig:Hips' , 'MOTION' , 'Frames: 69' , 'Frame Time: 0.0333333' ]
22+ )
2023
2124 def test_tree2 (self ):
2225 with open ('tests/test_mocapbank.bvh' ) as f :
2326 mocap = Bvh (f .read ())
24- self .assertEqual ([str (item ) for item in mocap .root ], ['HIERARCHY' , 'ROOT Hips' , 'MOTION' , 'Frames: 455' , 'Frame Time: 0.033333' ])
27+ self .assertEqual ([str (item ) for item in mocap .root ],
28+ ['HIERARCHY' , 'ROOT Hips' , 'MOTION' , 'Frames: 455' , 'Frame Time: 0.033333' ]
29+ )
2530
2631 def test_filter (self ):
2732 with open ('tests/test_freebvh.bvh' ) as f :
@@ -32,6 +37,7 @@ def test_bones(self):
3237 bones = []
3338 with open ('tests/test_freebvh.bvh' ) as f :
3439 mocap = Bvh (f .read ())
40+
3541 def iterate_joints (joint ):
3642 bones .append (str (joint ))
3743 for child in joint .filter ('JOINT' ):
@@ -108,7 +114,9 @@ def test_channels(self):
108114 with open ('tests/test_mocapbank.bvh' ) as f :
109115 mocap = Bvh (f .read ())
110116 self .assertEqual (mocap .joint_channels ('LeftElbow' ), ['Zrotation' , 'Xrotation' , 'Yrotation' ])
111- self .assertEqual (mocap .joint_channels ('Hips' ), ['Xposition' , 'Yposition' , 'Zposition' , 'Zrotation' , 'Xrotation' , 'Yrotation' ])
117+ self .assertEqual (mocap .joint_channels ('Hips' ),
118+ ['Xposition' , 'Yposition' , 'Zposition' , 'Zrotation' , 'Xrotation' , 'Yrotation' ]
119+ )
112120
113121 def test_frame_channel (self ):
114122 with open ('tests/test_mocapbank.bvh' ) as f :
@@ -118,7 +126,7 @@ def test_frame_channel(self):
118126 self .assertEqual (mocap .frame_joint_channel (22 , 'Neck' , 'Xrotation' ), - 6.77 )
119127 self .assertEqual (mocap .frame_joint_channel (22 , 'Head' , 'Yrotation' ), 8.47 )
120128
121- def test_frame_channel (self ):
129+ def test_frame_channel2 (self ):
122130 with open ('tests/test_freebvh.bvh' ) as f :
123131 mocap = Bvh (f .read ())
124132 self .assertEqual (mocap .frame_joint_channel (22 , 'mixamorig:Hips' , 'Xposition' ), 4.3314 )
@@ -128,7 +136,7 @@ def test_frame_iteration(self):
128136 mocap = Bvh (f .read ())
129137 x_accumulator = 0.0
130138 for i in range (0 , mocap .nframes ):
131- x_accumulator += mocap .frame_joint_channel (i , 'Hips' , 'Xposition' )
139+ x_accumulator += mocap .frame_joint_channel (i , 'Hips' , 'Xposition' )
132140 self .assertTrue (abs (- 19735.902699999995 - x_accumulator ) < 0.0001 )
133141
134142 def test_joints_names (self ):
@@ -151,16 +159,15 @@ def test_joint_parent(self):
151159 def test_frame_joint_multi_channels (self ):
152160 with open ('tests/test_mocapbank.bvh' ) as f :
153161 mocap = Bvh (f .read ())
154- rotation = mocap .frame_joint_channels (30 , 'Head' , ['Xrotation' , 'Yrotation' , 'Zrotation' ])
162+ rotation = mocap .frame_joint_channels (30 , 'Head' , ['Xrotation' , 'Yrotation' , 'Zrotation' ])
155163 self .assertEqual (rotation , [1.77 , 13.94 , - 7.42 ])
156164
157165 def test_frames_multi_channels (self ):
158166 with open ('tests/test_mocapbank.bvh' ) as f :
159167 mocap = Bvh (f .read ())
160- rotations = mocap .frames_joint_channels ('Head' , ['Xrotation' , 'Yrotation' , 'Zrotation' ])
168+ rotations = mocap .frames_joint_channels ('Head' , ['Xrotation' , 'Yrotation' , 'Zrotation' ])
161169 self .assertEqual (len (rotations ), mocap .nframes )
162170
163171
164172if __name__ == '__main__' :
165173 unittest .main ()
166-
0 commit comments