-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
94 lines (69 loc) · 3.6 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from nose.tools import raises
import numpy as np
from Elements import KinematicObject
def test_KinematicObject_init():
obj1 = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
obj2 = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0], [0.0], [1.0])
obj3 = KinematicObject(np.array([0.0, 0.0]), [0.0, 0.0], 1, [0.0], np.array([0.0]), [1.0])
assert True
@raises(ValueError)
def test_KinematicObject_Invalid_posvel_Sizes():
obj1 = KinematicObject([0.0, 0.0], [0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
obj2 = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0], [0.0, 0.0], [1.0])
obj3 = KinematicObject(np.array([0.0, 0.0]), [0.0, 0.0], 1, [0.0], np.array([0.0]), [1.0])
@raises(ValueError)
def test_KinematicObject_Invalid_rotvel_Sizes():
obj2 = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0], [0.0, 0.0], [1.0])
obj3 = KinematicObject(np.array([0.0, 0.0]), [0.0, 0.0], 1, [0.0], np.array([0.0]), [1.0])
@raises(ValueError)
def test_KinematicObject_Invalid_rotmom_Sizes():
obj2 = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0], [0.0], [1.0, 0.0])
def test_KinematicObject_point_dist():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
assert obj.dist([0.0, 1.0]) == 1.0
def test_KinematicObject_KinematicObject_dist():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
obj2 = KinematicObject([0.0, 1.0], [10.0, 0.0], 1, [0.0], [0.0], [1.0])
assert obj.dist(obj2) == 1.0
@raises(ValueError)
def test_KinematicObject_invalid_point_dist():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
assert obj.dist([0.0, 1.0, 0.0]) == 1.0
def test_KinematicObject_pos_step():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [1.0, 1.0])
print obj.step([0.0, 1.0], [0.0, 0.0], 1)
for i, j in zip(obj.step([0.0, 0.0], [1.0, 0.0], 1), (np.array([0., 2.]), np.array([0., 1.]),
np.array([1., 0.]), np.array([1., 0.]))):
print "Comparing {} and {}".format(i, j)
assert (i == j).all()
def test_KinematicObject_rot_step():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [0.5, 1.0])
print obj.step([0.0, 1.0], [1.0, 1.0], 1)
for i, j in zip(obj.step([0.0, 0.0], [0.0, 0.0], 1), (np.array([0., 2.]), np.array([0., 1.]),
np.array([4., 2.]), np.array([2., 1.]))):
print "Comparing {} and {}".format(i, j)
assert (i == j).all()
@raises(ValueError)
def test_KinematicObject_pos_exept_delt():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [0.5, 1.0])
print obj.step([0.0, 1.0], [1.0, 1.0], 1)
for i, j in zip(obj.step([0.0, 0.0], [0.0, 0.0], 0), (np.array([0., 2.]), np.array([0., 1.]),
np.array([4., 2.]), np.array([2., 1.]))):
print "Comparing {} and {}".format(i, j)
assert (i == j).all()
@raises(ValueError)
def test_KinematicObject_pos_exept_force():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [0.5, 1.0])
print obj.step([0.0, 1.0], [1.0, 1.0], 1)
for i, j in zip(obj.step([0.0], [0.0, 0.0], 1), (np.array([0., 2.]), np.array([0., 1.]),
np.array([4., 2.]), np.array([2., 1.]))):
print "Comparing {} and {}".format(i, j)
assert (i == j).all()
@raises(ValueError)
def test_KinematicObject_pos_exept_mom():
obj = KinematicObject([0.0, 0.0], [0.0, 0.0], 1, [0.0, 0.0], [0.0, 0.0], [0.5, 1.0])
print obj.step([0.0, 1.0], [1.0, 1.0], 1)
for i, j in zip(obj.step([0.0, 0.0], [0.0], 1), (np.array([0., 2.]), np.array([0., 1.]),
np.array([4., 2.]), np.array([2., 1.]))):
print "Comparing {} and {}".format(i, j)
assert (i == j).all()