Skip to content

Commit 615cea1

Browse files
authored
Merge pull request #1 from 20tab/feature/flake8
Feature/flake8
2 parents 7ce2082 + b054b86 commit 615cea1

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

bvh.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def __getitem__(self, key):
2727
for child in self.children:
2828
for index, item in enumerate(child.value):
2929
if item == key:
30-
if index+1 >= len(child.value):
30+
if index + 1 >= len(child.value):
3131
return None
3232
else:
33-
return child.value[index+1:]
34-
raise IndexError('key {0} not found'.format(key))
33+
return child.value[index + 1:]
34+
raise IndexError('key {} not found'.format(key))
3535

3636
def __repr__(self):
3737
return str(' '.join(self.value))
@@ -55,8 +55,7 @@ def tokenize(self):
5555
for char in self.data:
5656
if char not in ('\n', '\r'):
5757
accumulator += char
58-
else:
59-
if accumulator:
58+
elif accumulator:
6059
first_round.append(re.split('\\s+', accumulator.strip()))
6160
accumulator = ''
6261
node_stack = [self.root]

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
author='20Tab S.r.l.',
99
author_email='info@20tab.com',
1010
url='https://github.com/20tab/bvh-python',
11-
py_modules=['bvh'])
11+
py_modules=['bvh'],
12+
)

tests/test_bvh.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
23
from 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

164172
if __name__ == '__main__':
165173
unittest.main()
166-

0 commit comments

Comments
 (0)