mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-23 15:04:20 +00:00
Merge v1.0.0 (#682)
Co-authored-by: Kallinteris Andreas <30759571+Kallinteris-Andreas@users.noreply.github.com> Co-authored-by: Jet <38184875+jjshoots@users.noreply.github.com> Co-authored-by: Omar Younis <42100908+younik@users.noreply.github.com>
This commit is contained in:
22
tests/wrappers/test_lambda_observation.py
Normal file
22
tests/wrappers/test_lambda_observation.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Test suite for LambdaObservation wrappers."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gymnasium.spaces import Box
|
||||
from gymnasium.wrappers import TransformObservation
|
||||
from tests.testing_env import GenericTestEnv
|
||||
from tests.wrappers.utils import check_obs, record_action_as_obs_step, record_obs_reset
|
||||
|
||||
|
||||
def test_lambda_observation_wrapper():
|
||||
"""Tests lambda observation that the function is applied to both the reset and step observation."""
|
||||
env = GenericTestEnv(
|
||||
reset_func=record_obs_reset, step_func=record_action_as_obs_step
|
||||
)
|
||||
wrapped_env = TransformObservation(env, lambda _obs: _obs + 2, Box(2, 3))
|
||||
|
||||
obs, info = wrapped_env.reset(options={"obs": np.array([0], dtype=np.float32)})
|
||||
check_obs(env, wrapped_env, obs, info["obs"])
|
||||
|
||||
obs, _, _, _, info = wrapped_env.step(np.array([1], dtype=np.float32))
|
||||
check_obs(env, wrapped_env, obs, info["obs"])
|
Reference in New Issue
Block a user