mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-07 00:11:46 +00:00
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>
20 lines
742 B
Python
20 lines
742 B
Python
"""Test suite for LambdaAction wrapper."""
|
|
|
|
from gymnasium.spaces import Box
|
|
from gymnasium.wrappers import TransformAction
|
|
from tests.testing_env import GenericTestEnv
|
|
from tests.wrappers.utils import record_action_step
|
|
|
|
|
|
def test_lambda_action_wrapper():
|
|
"""Tests LambdaAction through checking that the action taken is transformed by function."""
|
|
env = GenericTestEnv(step_func=record_action_step)
|
|
wrapped_env = TransformAction(env, lambda action: action - 2, Box(2, 3))
|
|
|
|
sampled_action = wrapped_env.action_space.sample()
|
|
assert sampled_action not in env.action_space
|
|
|
|
_, _, _, _, info = wrapped_env.step(sampled_action)
|
|
assert info["action"] in env.action_space
|
|
assert sampled_action - 2 == info["action"]
|