Add (A)syncVectorEnv support for sub-envs with different observation spaces (#1140)

Co-authored-by: Reggie <72816837+reginald-mclean@users.noreply.github.com>
Co-authored-by: Reggie McLean <reginald.mclean@ryerson.ca>
This commit is contained in:
Mark Towers
2024-08-29 16:52:43 +01:00
committed by GitHub
parent ad8734d89b
commit 64fac8e80b
10 changed files with 584 additions and 55 deletions

View File

@@ -1,5 +1,7 @@
"""Test the `SyncVectorEnv` implementation."""
import re
import numpy as np
import pytest
@@ -139,7 +141,12 @@ def test_check_spaces_sync_vector_env():
env_fns = [make_env("CartPole-v1", i) for i in range(8)]
# FrozenLake-v1 - Discrete(16), action_space: Discrete(4)
env_fns[1] = make_env("FrozenLake-v1", 1)
with pytest.raises(RuntimeError):
with pytest.raises(
AssertionError,
match=re.escape(
"SyncVectorEnv(..., observation_mode='same') however the sub-environments observation spaces are not equivalent."
),
):
env = SyncVectorEnv(env_fns)
env.close()