From 51f6aa8b434793487d3356f10100d5aa9396bfce Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Tue, 4 Mar 2025 08:42:18 -0800 Subject: [PATCH] Store assets by address instead of value in MjSpec. PiperOrigin-RevId: 733343350 Change-Id: I42ee2a184ebff37a080dace0422bb61e1ba53527 --- python/mujoco/specs_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/mujoco/specs_test.py b/python/mujoco/specs_test.py index e400347e..ec2c0fbb 100644 --- a/python/mujoco/specs_test.py +++ b/python/mujoco/specs_test.py @@ -14,6 +14,7 @@ # ============================================================================== """Tests for mjSpec bindings.""" +import gc import inspect import os import textwrap @@ -750,6 +751,10 @@ class SpecsTest(absltest.TestCase): model = spec.compile() self.assertEqual(model.nmeshvert, 8) self.assertEqual(spec.assets['cube.obj'], cube) + self.assertIs( + spec.assets['cube.obj'], cube, + 'Asset dict should contain a reference, not a copy' + ) xml = """ @@ -766,6 +771,13 @@ class SpecsTest(absltest.TestCase): model = spec.compile() self.assertEqual(model.nmeshvert, 8) self.assertEqual(spec.assets['cube.obj'], cube) + self.assertIs( + spec.assets['cube.obj'], cube, + 'Asset dict should contain a reference, not a copy' + ) + del assets + gc.collect() + self.assertEqual(spec.assets['cube.obj'], cube) def test_include(self): included_xml = """