Skip to content

Commit

Permalink
Update helpers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Aug 29, 2020
1 parent 88882bd commit 1e42d1e
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions bindings/python/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'''
For testing iDynTree python bindings, we rely on the unittest standard python lib
'''
"""
For testing iDynTree python bindings, we rely on the unittest standard python lib
"""

import sys

sys.path.append("../../python/");
sys.path.append("../../../lib/python/");
sys.path.append("../../../lib/python/Debug/");
sys.path.append("../../python/")
sys.path.append("../../../lib/python/")
sys.path.append("../../../lib/python/Debug/")

import unittest
import numpy as np
import iDynTree
import random

class HelpersTest(unittest.TestCase):
'''Helper methods'''
"""Helper methods"""
def places(self):
return 7

Expand All @@ -32,7 +32,7 @@ def checkMatrixEqual(self, v1, v2, msg):
for c in range(0, v1.cols()):
self.checkApproxEqual(v1.getVal(r, c), v2.getVal(r, c), msg=msg + ":" + msgMore)

'''tests'''
"""tests"""
def testDynSizeFromPython(self):
pos = [-1.0, 2, 3.0]
p1 = iDynTree.VectorDynSize.FromPython(pos)
Expand All @@ -42,7 +42,7 @@ def testDynSizeFromPython(self):
p2.setVal(2, pos[2])
self.checkVectorEqual(p1, p2, "helper does not properly create vector (vectors are not equal)")

def testDynSizePythonCostructor(self):
def testDynSizePythonConstructor(self):
pos = [-1.0, 2, 3.0]
p1 = iDynTree.VectorDynSize(pos)
p2 = iDynTree.VectorDynSize(3)
Expand Down Expand Up @@ -81,7 +81,7 @@ def testWrenchFromPython(self):
p2.setVal(5, pos[5])
self.checkVectorEqual(p1, p2, "helper does not properly create vector (vectors are not equal)")

def testWrenchPythonCostructor(self):
def testWrenchPythonConstructor(self):
pos = [-1.0, 2, 3.0, 4.0, 5.5, 6.9]
p1 = iDynTree.Wrench(pos)
p2 = iDynTree.Wrench()
Expand All @@ -105,7 +105,7 @@ def testTwistFromPython(self):
p2.setVal(5, pos[5])
self.checkVectorEqual(p1, p2, "helper does not properly create vector (vectors are not equal)")

def testTwistPythonCostructor(self):
def testTwistPythonConstructor(self):
pos = [-1.0, 2, 3.0, 4.0, 5.5, 6.9]
p1 = iDynTree.Twist(pos)
p2 = iDynTree.Twist()
Expand All @@ -129,7 +129,7 @@ def testSpatialAccFromPython(self):
p2.setVal(5, pos[5])
self.checkVectorEqual(p1, p2, "helper does not properly create vector (vectors are not equal)")

def testSpatialAccPythonCostructor(self):
def testSpatialAccPythonConstructor(self):
pos = [-1.0, 2, 3.0, 4.0, 5.5, 6.9]
p1 = iDynTree.SpatialAcc(pos)
p2 = iDynTree.SpatialAcc()
Expand Down Expand Up @@ -274,7 +274,10 @@ def testToNumPy(self):
p2[2] = pos[2]

p2_asNumpy = p2.toNumPy()
# TODO: check the type is a numpy array

if not isinstance(p2_asNumpy, np.ndarray):
raise TypeError("Conversion to NumPy failed")

self.checkVectorEqual(pos, p2_asNumpy, "helper does not returned a well-formed array")


Expand Down

0 comments on commit 1e42d1e

Please sign in to comment.