Skip to content

Commit

Permalink
Fix test being flaky due to non-determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneteoh committed Apr 10, 2024
1 parent 9340499 commit 1e015d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/unit/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def test_executed_jp_action(self):
with self.subTest(task_cls=task_cls):
task = self.get_task(
task_cls, JointPosition(True))
demos = task.get_demos(5, live_demos=True)
num_episodes = 20
demos = task.get_demos(num_episodes, live_demos=True)
total_reward = 0.0
# Check if executed joint position action is stored
for demo in demos:
jp_action = []
Expand All @@ -287,6 +289,9 @@ def test_executed_jp_action(self):
obs, reward, term = task.step(action)
if term:
break
self.assertEqual(reward, 1.0)
total_reward += reward

success_rate = total_reward / num_episodes
self.assertTrue(success_rate >= 0.9)
self.env.shutdown()

0 comments on commit 1e015d2

Please sign in to comment.