2022-09-26 09:46:53 +02: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
|
|
|
|
2023-01-12 17:21:56 +01:00
|
|
|
import gymnasium as gym
|
2022-09-26 09:46:53 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import fancy_gym
|
|
|
|
from test.utils import run_env, run_env_determinism
|
|
|
|
|
2023-08-14 16:09:28 +02:00
|
|
|
DMC_IDS = [spec.id for spec in gym.envs.registry.values() if
|
2023-08-14 16:47:05 +02:00
|
|
|
spec.id.startswith('dm_control/')
|
|
|
|
and 'compatibility-env-v0' not in spec.id
|
|
|
|
and 'lqr-lqr' not in spec.id]
|
|
|
|
DMC_MP_IDS = fancy_gym.ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all']
|
2022-09-26 09:46:53 +02:00
|
|
|
SEED = 1
|
|
|
|
|
|
|
|
|
2023-08-14 16:09:28 +02:00
|
|
|
@pytest.mark.parametrize('env_id', DMC_IDS)
|
2023-01-12 17:21:56 +01:00
|
|
|
def test_step_dm_control_functionality(env_id: str):
|
2022-09-26 09:46:53 +02:00
|
|
|
"""Tests that suite step environments run without errors using random actions."""
|
2023-01-17 08:27:29 +01:00
|
|
|
run_env(env_id, 5000, wrappers=[gym.wrappers.FlattenObservation])
|
2022-09-26 09:46:53 +02:00
|
|
|
|
|
|
|
|
2023-08-14 16:09:28 +02:00
|
|
|
@pytest.mark.parametrize('env_id', DMC_IDS)
|
2023-01-12 17:21:56 +01:00
|
|
|
def test_step_dm_control_determinism(env_id: str):
|
2022-09-26 09:46:53 +02:00
|
|
|
"""Tests that for step environments identical seeds produce identical trajectories."""
|
2023-01-17 08:27:29 +01:00
|
|
|
run_env_determinism(env_id, SEED, 5000, wrappers=[gym.wrappers.FlattenObservation])
|
2022-09-26 09:46:53 +02:00
|
|
|
|
2023-08-14 16:47:05 +02:00
|
|
|
|
2023-08-14 16:09:28 +02:00
|
|
|
@pytest.mark.parametrize('env_id', DMC_MP_IDS)
|
2022-09-26 09:46:53 +02:00
|
|
|
def test_bb_dmc_functionality(env_id: str):
|
|
|
|
"""Tests that black box environments run without errors using random actions."""
|
|
|
|
run_env(env_id)
|
|
|
|
|
2023-08-14 16:47:05 +02:00
|
|
|
|
2023-08-14 16:09:28 +02:00
|
|
|
@pytest.mark.parametrize('env_id', DMC_MP_IDS)
|
2022-09-26 09:46:53 +02:00
|
|
|
def test_bb_dmc_determinism(env_id: str):
|
|
|
|
"""Tests that for black box environment identical seeds produce identical trajectories."""
|
|
|
|
run_env_determinism(env_id, SEED)
|