mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-31 10:09:53 +00:00
* Allows a new RNG to be generated with seed=-1 and updated env_checker to fix bug if environment doesn't use np_random in reset
* Revert "fixed `gym.vector.make` where the checker was being applied in the opposite case than was intended to (#2871)"
This reverts commit 519dfd9117
.
* Remove bad pushed commits
* Fixed spelling in core.py
* Pins pytest to the last py 3.6 version
* Allow Box automatic scalar shape
* Add test box and change default from () to (1,)
* update Box shape inference with more strict checking
* Update the box shape and add check on the custom Box shape
* Removed incorrect shape type and assert shape code
* Update the Box and associated tests
* Remove all folders and files from pyright exclude
* Revert issues
* Push RedTachyon code review
* Add Python Platform
* Remove play from pyright check
* Fixed CI issues
* remove mujoco env type hinting
* Fixed pixel observation test
* Added some new type hints
* Fixed CI errors
* Fixed CI errors
* Remove play.py from exlucde pyright
* Fixed pyright issues
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import pytest
|
|
|
|
import gym
|
|
from gym import spaces
|
|
from gym.wrappers import TimeAwareObservation
|
|
|
|
|
|
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
|
|
def test_time_aware_observation(env_id):
|
|
env = gym.make(env_id, disable_env_checker=True)
|
|
wrapped_env = TimeAwareObservation(env)
|
|
|
|
assert isinstance(env.observation_space, spaces.Box)
|
|
assert isinstance(wrapped_env.observation_space, spaces.Box)
|
|
assert wrapped_env.observation_space.shape[0] == env.observation_space.shape[0] + 1
|
|
|
|
obs = env.reset()
|
|
wrapped_obs = wrapped_env.reset()
|
|
assert wrapped_env.t == 0.0
|
|
assert wrapped_obs[-1] == 0.0
|
|
assert wrapped_obs.shape[0] == obs.shape[0] + 1
|
|
|
|
wrapped_obs, _, _, _ = wrapped_env.step(env.action_space.sample())
|
|
assert wrapped_env.t == 1.0
|
|
assert wrapped_obs[-1] == 1.0
|
|
assert wrapped_obs.shape[0] == obs.shape[0] + 1
|
|
|
|
wrapped_obs, _, _, _ = wrapped_env.step(env.action_space.sample())
|
|
assert wrapped_env.t == 2.0
|
|
assert wrapped_obs[-1] == 2.0
|
|
assert wrapped_obs.shape[0] == obs.shape[0] + 1
|
|
|
|
wrapped_obs = wrapped_env.reset()
|
|
assert wrapped_env.t == 0.0
|
|
assert wrapped_obs[-1] == 0.0
|
|
assert wrapped_obs.shape[0] == obs.shape[0] + 1
|