Skip to content

Commit

Permalink
Revert commit d627374.
Browse files Browse the repository at this point in the history
This commit requires a new binary build, and therefore breaks compatibility with version 2.1.3.

Fixes google-deepmind#217.

Change-Id: I1e08b6fd2c468e3845e2166a1e4cc9d265de64de
  • Loading branch information
saran-t authored and kevinzakka committed May 24, 2022
1 parent 427380d commit c52240a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 77 deletions.
1 change: 0 additions & 1 deletion include/mjvisualize.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ typedef enum mjtFrame_ { // frame visualization
mjFRAME_SITE, // site frames
mjFRAME_CAMERA, // camera frames
mjFRAME_LIGHT, // light frames
mjFRAME_CONTACT, // contact frames
mjFRAME_WORLD, // world frame

mjNFRAME // number of visualization frames
Expand Down
5 changes: 2 additions & 3 deletions introspect/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,8 @@
('mjFRAME_SITE', 3),
('mjFRAME_CAMERA', 4),
('mjFRAME_LIGHT', 5),
('mjFRAME_CONTACT', 6),
('mjFRAME_WORLD', 7),
('mjNFRAME', 8),
('mjFRAME_WORLD', 6),
('mjNFRAME', 7),
]),
)),
('mjtVisFlag',
Expand Down
142 changes: 70 additions & 72 deletions python/mujoco/bindings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,93 +665,91 @@ def test_enum_from_int(self):

def test_enum_as_index(self):
x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
self.assertEqual(x[mujoco.mjtFrame.mjFRAME_WORLD], 'h')
self.assertEqual(x[mujoco.mjtFrame.mjNFRAME], 'h')
self.assertEqual(
x[mujoco.mjtFrame.mjFRAME_GEOM:mujoco.mjtFrame.mjFRAME_CAMERA],
['c', 'd'])

def test_enum_ops(self):
# Note: when modifying this test, make sure the enum value is an odd number
# so that the division tests are correctly exercised.
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD, 7)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD, 7.0)
self.assertEqual(7, mujoco.mjtFrame.mjFRAME_WORLD)
self.assertEqual(7.0, mujoco.mjtFrame.mjFRAME_WORLD)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD,
mujoco.mjtFrame.mjFRAME_WORLD)
self.assertNotEqual(mujoco.mjtFrame.mjFRAME_WORLD,
mujoco.mjtFrame.mjFRAME_NONE)

self.assertEqual(-mujoco.mjtFrame.mjFRAME_WORLD, -7)
self.assertIsInstance(-mujoco.mjtFrame.mjFRAME_WORLD, int)

self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD + 1, 8)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD + 1, int)
self.assertEqual(2 + mujoco.mjtFrame.mjFRAME_WORLD, 9)
self.assertIsInstance(2 + mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD + 1.75, 8.75)
self.assertEqual(2.75 + mujoco.mjtFrame.mjFRAME_WORLD, 9.75)

self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD - 2, 5)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD - 2, int)
self.assertEqual(8 - mujoco.mjtFrame.mjFRAME_WORLD, 1)
self.assertIsInstance(8 - mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD - 2.25, 4.75)
self.assertEqual(8.25 - mujoco.mjtFrame.mjFRAME_WORLD, 1.25)

self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD * 3, 21)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD * 3, int)
self.assertEqual(3 * mujoco.mjtFrame.mjFRAME_WORLD, 21)
self.assertIsInstance(3 * mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD * 3.5, 24.5)
self.assertEqual(3.5 * mujoco.mjtFrame.mjFRAME_WORLD, 24.5)

self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD / 2, 3.5)
self.assertEqual(17.5 / mujoco.mjtFrame.mjFRAME_WORLD, 2.5)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD // 2, 3)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD // 2, int)
self.assertEqual(-mujoco.mjtFrame.mjFRAME_WORLD // 2, -4)
self.assertIsInstance(-mujoco.mjtFrame.mjFRAME_WORLD // 2, int)
self.assertEqual(20 // mujoco.mjtFrame.mjFRAME_WORLD, 2)
self.assertIsInstance(20 // mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(-20 // mujoco.mjtFrame.mjFRAME_WORLD, -3)
self.assertIsInstance(-20 // mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD // 2.0, 3)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD // 2.0, float)
self.assertEqual(-mujoco.mjtFrame.mjFRAME_WORLD // 2.0, -4)
self.assertIsInstance(-mujoco.mjtFrame.mjFRAME_WORLD // 2.0, float)
self.assertEqual(20.0 // mujoco.mjtFrame.mjFRAME_WORLD, 2)
self.assertIsInstance(20.0 // mujoco.mjtFrame.mjFRAME_WORLD, float)
self.assertEqual(-20 // mujoco.mjtFrame.mjFRAME_WORLD, -3)
self.assertIsInstance(-20.0 // mujoco.mjtFrame.mjFRAME_WORLD, float)

self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD % 4, 3)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD % 4, int)
self.assertEqual(-mujoco.mjtFrame.mjFRAME_WORLD % -4, -3)
self.assertIsInstance(-mujoco.mjtFrame.mjFRAME_WORLD % -4, int)
self.assertEqual(-mujoco.mjtFrame.mjFRAME_WORLD % 4, 1)
self.assertIsInstance(-mujoco.mjtFrame.mjFRAME_WORLD % 4, int)
self.assertEqual(mujoco.mjtFrame.mjFRAME_WORLD % -4, -1)
self.assertIsInstance(mujoco.mjtFrame.mjFRAME_WORLD % -4, int)
self.assertEqual(9 % mujoco.mjtFrame.mjFRAME_WORLD, 2)
self.assertIsInstance(9 % mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(-9 % -mujoco.mjtFrame.mjFRAME_WORLD, -2)
self.assertIsInstance(-9 % -mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(-9 % mujoco.mjtFrame.mjFRAME_WORLD, 5)
self.assertIsInstance(-9 % mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(9 % -mujoco.mjtFrame.mjFRAME_WORLD, -5)
self.assertIsInstance(9 % -mujoco.mjtFrame.mjFRAME_WORLD, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME, 7)
self.assertEqual(mujoco.mjtFrame.mjNFRAME, 7.0)
self.assertEqual(7, mujoco.mjtFrame.mjNFRAME)
self.assertEqual(7.0, mujoco.mjtFrame.mjNFRAME)
self.assertEqual(mujoco.mjtFrame.mjNFRAME, mujoco.mjtFrame.mjNFRAME)
self.assertNotEqual(mujoco.mjtFrame.mjNFRAME, mujoco.mjtFrame.mjFRAME_NONE)

self.assertEqual(-mujoco.mjtFrame.mjNFRAME, -7)
self.assertIsInstance(-mujoco.mjtFrame.mjNFRAME, int)

self.assertEqual(mujoco.mjtFrame.mjNFRAME + 1, 8)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME + 1, int)
self.assertEqual(2 + mujoco.mjtFrame.mjNFRAME, 9)
self.assertIsInstance(2 + mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME + 1.75, 8.75)
self.assertEqual(2.75 + mujoco.mjtFrame.mjNFRAME, 9.75)

self.assertEqual(mujoco.mjtFrame.mjNFRAME - 2, 5)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME - 2, int)
self.assertEqual(8 - mujoco.mjtFrame.mjNFRAME, 1)
self.assertIsInstance(8 - mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME - 2.25, 4.75)
self.assertEqual(8.25 - mujoco.mjtFrame.mjNFRAME, 1.25)

self.assertEqual(mujoco.mjtFrame.mjNFRAME * 3, 21)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME * 3, int)
self.assertEqual(3 * mujoco.mjtFrame.mjNFRAME, 21)
self.assertIsInstance(3 * mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME * 3.5, 24.5)
self.assertEqual(3.5 * mujoco.mjtFrame.mjNFRAME, 24.5)

self.assertEqual(mujoco.mjtFrame.mjNFRAME / 2, 3.5)
self.assertEqual(17.5 / mujoco.mjtFrame.mjNFRAME, 2.5)
self.assertEqual(mujoco.mjtFrame.mjNFRAME // 2, 3)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME // 2, int)
self.assertEqual(-mujoco.mjtFrame.mjNFRAME // 2, -4)
self.assertIsInstance(-mujoco.mjtFrame.mjNFRAME // 2, int)
self.assertEqual(20 // mujoco.mjtFrame.mjNFRAME, 2)
self.assertIsInstance(20 // mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(-20 // mujoco.mjtFrame.mjNFRAME, -3)
self.assertIsInstance(-20 // mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME // 2.0, 3)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME // 2.0, float)
self.assertEqual(-mujoco.mjtFrame.mjNFRAME // 2.0, -4)
self.assertIsInstance(-mujoco.mjtFrame.mjNFRAME // 2.0, float)
self.assertEqual(20.0 // mujoco.mjtFrame.mjNFRAME, 2)
self.assertIsInstance(20.0 // mujoco.mjtFrame.mjNFRAME, float)
self.assertEqual(-20 // mujoco.mjtFrame.mjNFRAME, -3)
self.assertIsInstance(-20.0 // mujoco.mjtFrame.mjNFRAME, float)

self.assertEqual(mujoco.mjtFrame.mjNFRAME % 4, 3)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME % 4, int)
self.assertEqual(-mujoco.mjtFrame.mjNFRAME % -4, -3)
self.assertIsInstance(-mujoco.mjtFrame.mjNFRAME % -4, int)
self.assertEqual(-mujoco.mjtFrame.mjNFRAME % 4, 1)
self.assertIsInstance(-mujoco.mjtFrame.mjNFRAME % 4, int)
self.assertEqual(mujoco.mjtFrame.mjNFRAME % -4, -1)
self.assertIsInstance(mujoco.mjtFrame.mjNFRAME % -4, int)
self.assertEqual(9 % mujoco.mjtFrame.mjNFRAME, 2)
self.assertIsInstance(9 % mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(-9 % -mujoco.mjtFrame.mjNFRAME, -2)
self.assertIsInstance(-9 % -mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(-9 % mujoco.mjtFrame.mjNFRAME, 5)
self.assertIsInstance(-9 % mujoco.mjtFrame.mjNFRAME, int)
self.assertEqual(9 % -mujoco.mjtFrame.mjNFRAME, -5)
self.assertIsInstance(9 % -mujoco.mjtFrame.mjNFRAME, int)

with self.assertRaises(ZeroDivisionError):
_ = mujoco.mjtFrame.mjFRAME_WORLD / 0
_ = mujoco.mjtFrame.mjNFRAME / 0
with self.assertRaises(ZeroDivisionError):
_ = 1 / mujoco.mjtFrame.mjFRAME_NONE
with self.assertRaises(ZeroDivisionError):
_ = mujoco.mjtFrame.mjFRAME_WORLD // 0
_ = mujoco.mjtFrame.mjNFRAME // 0
with self.assertRaises(ZeroDivisionError):
_ = 1 // mujoco.mjtFrame.mjFRAME_NONE
with self.assertRaises(ZeroDivisionError):
_ = mujoco.mjtFrame.mjFRAME_WORLD % 0
_ = mujoco.mjtFrame.mjNFRAME % 0
with self.assertRaises(ZeroDivisionError):
_ = 1 % mujoco.mjtFrame.mjFRAME_NONE

Expand Down
2 changes: 1 addition & 1 deletion sample/simulate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ void makerendering(int oldstate) {
"Frame",
2,
&(vopt.frame),
"None\nBody\nGeom\nSite\nCamera\nLight\nContact\nWorld"
"None\nBody\nGeom\nSite\nCamera\nLight\nWorld"
},
{
mjITEM_BUTTON,
Expand Down

0 comments on commit c52240a

Please sign in to comment.