MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / testSimpleCopy

Method testSimpleCopy

dm_control/mjcf/copier_test.py:32–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30class CopierTest(absltest.TestCase):
31
32 def testSimpleCopy(self):
33 mjcf_model = parser.from_path(_TEST_MODEL_XML)
34 mixin = mjcf.RootElement(model='test_mixin')
35 mixin.compiler.boundmass = 1
36 mjcf_model.include_copy(mixin)
37 self.assertEqual(mjcf_model.model, 'test') # Model name should not change
38 self.assertEqual(mjcf_model.compiler.boundmass, mixin.compiler.boundmass)
39 mixin.compiler.boundinertia = 2
40 mjcf_model.include_copy(mixin)
41 self.assertEqual(mjcf_model.compiler.boundinertia,
42 mixin.compiler.boundinertia)
43 mixin.compiler.boundinertia = 1
44 with self.assertRaisesRegex(ValueError, 'Conflicting values'):
45 mjcf_model.include_copy(mixin)
46 mixin.worldbody.add('body', name='b_0', pos=[0, 1, 2])
47 mjcf_model.include_copy(mixin, override_attributes=True)
48 self.assertEqual(mjcf_model.compiler.boundmass, mixin.compiler.boundmass)
49 self.assertEqual(mjcf_model.compiler.boundinertia,
50 mixin.compiler.boundinertia)
51 np.testing.assert_array_equal(mjcf_model.worldbody.body['b_0'].pos,
52 [0, 1, 2])
53
54 def testCopyingWithReference(self):
55 sensor_mixin = mjcf.RootElement('sensor_mixin')

Callers

nothing calls this directly

Calls 3

include_copyMethod · 0.80
assertEqualMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected