Files
Gymnasium/tests/wrappers/test_resize_observation.py

23 lines
763 B
Python
Raw Normal View History

import pytest
2022-09-08 10:10:07 +01:00
import gymnasium
from gymnasium import spaces
from gymnasium.wrappers import ResizeObservation
2021-07-29 02:26:34 +02:00
2022-07-23 15:38:52 +01:00
@pytest.mark.parametrize("env_id", ["CarRacing-v2"])
2021-07-29 02:26:34 +02:00
@pytest.mark.parametrize("shape", [16, 32, (8, 5), [10, 7]])
def test_resize_observation(env_id, shape):
2022-09-08 10:10:07 +01:00
env = gymnasium.make(env_id, disable_env_checker=True)
env = ResizeObservation(env, shape)
assert isinstance(env.observation_space, spaces.Box)
assert env.observation_space.shape[-1] == 3
obs, _ = env.reset()
if isinstance(shape, int):
assert env.observation_space.shape[:2] == (shape, shape)
assert obs.shape == (shape, shape, 3)
else:
2019-07-13 06:10:11 +08:00
assert env.observation_space.shape[:2] == tuple(shape)
assert obs.shape == tuple(shape) + (3,)