2023-01-17 08:27:29 +01:00
|
|
|
from itertools import chain
|
2023-01-12 17:21:56 +01:00
|
|
|
from typing import Callable
|
2022-09-26 09:46:53 +02:00
|
|
|
|
2022-09-26 08:39:54 +02:00
|
|
|
import fancy_gym
|
2023-01-12 17:21:56 +01:00
|
|
|
import gymnasium as gym
|
2022-09-26 08:39:54 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from test.utils import run_env, run_env_determinism
|
|
|
|
|
2022-10-20 10:10:44 +02:00
|
|
|
CUSTOM_IDS = [id for id, spec in gym.envs.registry.items() if
|
2023-01-12 17:21:56 +01:00
|
|
|
not isinstance(spec.entry_point, Callable) and
|
2022-09-26 08:39:54 +02:00
|
|
|
"fancy_gym" in spec.entry_point and 'make_bb_env_helper' not in spec.entry_point]
|
2023-08-14 16:47:05 +02:00
|
|
|
CUSTOM_MP_IDS = fancy_gym.ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all']
|
2022-09-26 08:39:54 +02:00
|
|
|
SEED = 1
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('env_id', CUSTOM_IDS)
|
2022-09-26 09:46:53 +02:00
|
|
|
def test_step_fancy_functionality(env_id: str):
|
2022-09-26 08:39:54 +02:00
|
|
|
"""Tests that step environments run without errors using random actions."""
|
|
|
|
run_env(env_id)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('env_id', CUSTOM_IDS)
|
2022-09-26 09:46:53 +02:00
|
|
|
def test_step_fancy_determinism(env_id: str):
|
2022-09-26 08:39:54 +02:00
|
|
|
"""Tests that for step environments identical seeds produce identical trajectories."""
|
2022-09-26 09:46:53 +02:00
|
|
|
run_env_determinism(env_id, SEED)
|
2022-09-26 08:39:54 +02:00
|
|
|
|
|
|
|
|
2022-09-26 09:46:53 +02:00
|
|
|
@pytest.mark.parametrize('env_id', CUSTOM_MP_IDS)
|
|
|
|
def test_bb_fancy_functionality(env_id: str):
|
2022-09-26 08:39:54 +02:00
|
|
|
"""Tests that black box environments run without errors using random actions."""
|
|
|
|
run_env(env_id)
|
|
|
|
|
|
|
|
|
2022-09-26 09:46:53 +02:00
|
|
|
@pytest.mark.parametrize('env_id', CUSTOM_MP_IDS)
|
|
|
|
def test_bb_fancy_determinism(env_id: str):
|
2022-09-26 08:39:54 +02:00
|
|
|
"""Tests that for black box environment identical seeds produce identical trajectories."""
|
2022-09-26 09:46:53 +02:00
|
|
|
run_env_determinism(env_id, SEED)
|