Skip to content

Commit 2abb2e2

Browse files
quaglacopybara-github
authored andcommitted
Add further MJX bind tests to clarify dimensions.
Fixes #2463. PiperOrigin-RevId: 731674489 Change-Id: I9e21a2dd0b0636c94b2b917615889b9d721d542d
1 parent 9c31494 commit 2abb2e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mjx/mujoco/mjx/_src/support_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ def test_bind(self):
200200
# test getting
201201
np.testing.assert_array_equal(mx.bind(s.bodies).pos, m.body_pos)
202202
np.testing.assert_array_equal(dx.bind(mx, s.bodies).xpos, d.xpos)
203+
np.testing.assert_array_equal(m.bind(s.bodies[0]).mass, m.body_mass[0])
204+
np.testing.assert_array_equal(m.bind(s.bodies[0:1]).mass, [m.body_mass[0]])
205+
np.testing.assert_array_equal(mx.bind(s.bodies[0]).mass, m.body_mass[0])
206+
np.testing.assert_array_equal(mx.bind(s.bodies[0:1]).mass, [m.body_mass[0]])
203207
for i in range(m.nbody):
204208
np.testing.assert_array_equal(m.bind(s.bodies[i]).pos, m.body_pos[i, :])
205209
np.testing.assert_array_equal(mx.bind(s.bodies[i]).pos, m.body_pos[i, :])
@@ -224,6 +228,8 @@ def test_bind(self):
224228
np.testing.assert_array_equal(mx.bind(s.joints).axis, m.jnt_axis)
225229
np.testing.assert_array_equal(mx.bind(s.joints).qposadr, m.jnt_qposadr)
226230
np.testing.assert_array_equal(mx.bind(s.joints).dofadr, m.jnt_dofadr)
231+
np.testing.assert_array_equal(dx.bind(mx, s.joints[1]).id, 1)
232+
np.testing.assert_array_equal(dx.bind(mx, s.joints[1:2]).id, [1])
227233
qposnum = [4, 1, 1] # one ball joint (4) and two slide joints (1)
228234
dofnum = [3, 1, 1] # one ball joint (3) and two slide joints (1)
229235
for i in range(m.njnt):

0 commit comments

Comments
 (0)