bindings_Symmetric3.py
Go to the documentation of this file.
1 import unittest
2 
3 import numpy as np
4 import pinocchio as pin
5 from pinocchio.utils import eye, zero
6 from test_case import PinocchioTestCase as TestCase
7 
8 
9 class TestSymmetric3Bindings(TestCase):
10  def test_zero_getter(self):
11  S = pin.Symmetric3.Zero()
12  self.assertTrue(np.allclose(zero(6), S.data))
13 
15  S = pin.Symmetric3.Identity()
16  id_vec = np.array([1.0, 0.0, 1.0, 0.0, 0.0, 1.0])
17  id_matrix = pin.Symmetric3(id_vec).matrix()
18  self.assertTrue(np.allclose(eye(3), id_matrix))
19  self.assertTrue(np.allclose(np.array([1.0, 0.0, 1.0, 0.0, 0.0, 1.0]), S.data))
20  self.assertTrue(np.allclose(eye(3), S.matrix()))
21 
23  S = pin.Symmetric3.Identity()
24  S.setRandom()
25  self.assertFalse(np.allclose(eye(3), S.matrix()))
26  S_matrix = S.matrix()
27  tri_upper = np.triu(S_matrix, k=1)
28  tri_lower = np.tril(S_matrix, k=-1)
29  self.assertTrue(np.allclose(tri_upper, tri_lower.T))
30 
31  def test_setZero(self):
32  S = pin.Symmetric3.Zero()
33  S.setRandom()
34  S.setZero()
35  self.assertTrue(np.allclose(zero(6), S.data))
36 
38  S = pin.Symmetric3.Zero()
39  S.setIdentity()
40  self.assertTrue(np.allclose(eye(3), S.matrix()))
41 
42  def test_setDiagonal(self):
43  S = pin.Symmetric3.Zero()
44  S.setDiagonal(np.ones(3) * 2)
45  self.assertTrue(np.allclose(eye(3) * 2, S.matrix()))
46 
47 
48 if __name__ == "__main__":
49  unittest.main()
bindings_Symmetric3.TestSymmetric3Bindings.test_setRandom_matrix_conversion
def test_setRandom_matrix_conversion(self)
Definition: bindings_Symmetric3.py:22
bindings_Symmetric3.TestSymmetric3Bindings.test_zero_getter
def test_zero_getter(self)
Definition: bindings_Symmetric3.py:10
bindings_Symmetric3.TestSymmetric3Bindings.test_identity_getters_matrix_conversion
def test_identity_getters_matrix_conversion(self)
Definition: bindings_Symmetric3.py:14
bindings_Symmetric3.TestSymmetric3Bindings.test_setZero
def test_setZero(self)
Definition: bindings_Symmetric3.py:31
pinocchio.utils
Definition: bindings/python/pinocchio/utils.py:1
pinocchio.utils.eye
def eye(n)
Definition: bindings/python/pinocchio/utils.py:32
bindings_Symmetric3.TestSymmetric3Bindings
Definition: bindings_Symmetric3.py:9
bindings_Symmetric3.TestSymmetric3Bindings.test_setDiagonal
def test_setDiagonal(self)
Definition: bindings_Symmetric3.py:42
bindings_Symmetric3.TestSymmetric3Bindings.test_setIdentity_matrix_conversion
def test_setIdentity_matrix_conversion(self)
Definition: bindings_Symmetric3.py:37
pinocchio.utils.zero
def zero(n)
Definition: bindings/python/pinocchio/utils.py:37


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:25