Skip to content

Commit

Permalink
Add full action masking support, expand and refactor testing (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottower authored Jul 20, 2023
2 parents cbeeec2 + 22ae565 commit 7021b7f
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- run: python -m pip install pre-commit
- run: python -m pre_commit --version
- run: python -m pre_commit install
- run: python -m pre_commit run --all-files
- run: python -m pre_commit run --all-files --show-diff-on-failure
16 changes: 15 additions & 1 deletion supersuit/utils/obs_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,18 @@ def add(self, in_obs):
if len(self.obs_queue) > self.delay:
return self.obs_queue.popleft()
else:
return np.zeros_like(in_obs)
if isinstance(in_obs, np.ndarray):
return np.zeros_like(in_obs)
elif (
isinstance(in_obs, dict)
and "observation" in in_obs.keys()
and "action_mask" in in_obs.keys()
):
return {
"observation": np.zeros_like(in_obs["observation"]),
"action_mask": np.ones_like(in_obs["action_mask"]),
}
else:
raise TypeError(
"Observation must be of type np.ndarray or dictionary with keys 'observation' and 'action_mask'"
)
Loading

0 comments on commit 7021b7f

Please sign in to comment.