Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full action masking support, expand and refactor testing #227

Merged
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