bindings_std_map.py
Go to the documentation of this file.
1 import pickle
2 import unittest
3 from pathlib import Path
4 
5 import numpy as np
6 import pinocchio as pin
7 from test_case import PinocchioTestCase as TestCase
8 
9 
10 class TestStdMap(TestCase):
11  def setUp(self):
12  pass
13 
14  def test_pickle(self):
15  map = pin.StdMap_String_VectorXd()
16  keys = []
17  for k in range(100):
18  key_name = "key_" + str(k + 1)
19  keys.append(key_name)
20  map[key_name] = np.random.rand(10)
21 
22  pickle.dump(map, Path("save_std_map.p").open("wb"))
23 
24  map_loaded = pickle.load(Path("save_std_map.p").open("rb"))
25  for key in keys:
26  self.assertApprox(map[key], map_loaded[key])
27 
28 
29 if __name__ == "__main__":
30  unittest.main()
bindings_std_map.TestStdMap.setUp
def setUp(self)
Definition: bindings_std_map.py:11
bindings_std_map.TestStdMap.test_pickle
def test_pickle(self)
Definition: bindings_std_map.py:14
bindings_std_map.TestStdMap
Definition: bindings_std_map.py:10
append-urdf-model-with-another-model.open
open
Definition: append-urdf-model-with-another-model.py:78


pinocchio
Author(s):
autogenerated on Fri Jan 10 2025 03:41:29