Skip to content

Commit 8de9b4e

Browse files
Merge pull request #2462 from jjyyxx:main
PiperOrigin-RevId: 731710330 Change-Id: If87dd2c06123bd9ddfc62b63370c8fedf320e721
2 parents 2abb2e2 + 2039629 commit 8de9b4e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

python/mujoco/specs.cc

+3
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ PYBIND11_MODULE(_specs, m) {
393393
mjSpec.def("copy", [](const MjSpec& self) -> MjSpec {
394394
return MjSpec(self);
395395
});
396+
mjSpec.def_property_readonly("_address", [](const MjSpec& self) {
397+
return reinterpret_cast<uintptr_t>(self.ptr);
398+
});
396399
mjSpec.def_property(
397400
"copy_during_attach",
398401
[](MjSpec& self) {

python/mujoco/specs_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -1159,5 +1159,15 @@ def test_incorrect_hfield_size(self):
11591159
):
11601160
model_spec.compile()
11611161

1162+
def test_address(self):
1163+
spec1 = mujoco.MjSpec()
1164+
spec2 = mujoco.MjSpec()
1165+
spec3 = spec1.copy()
1166+
1167+
self.assertGreater(spec1._address, 0)
1168+
self.assertGreater(spec2._address, 0)
1169+
self.assertGreater(spec3._address, 0)
1170+
self.assertLen({spec1._address, spec2._address, spec3._address}, 3)
1171+
11621172
if __name__ == '__main__':
11631173
absltest.main()

0 commit comments

Comments
 (0)