<s> import numpy as np <EOL> from nose2 import tools <EOL> from rllab . envs . box2d . car_parking_env import CarParkingEnv <EOL> from rllab . envs . box2d . cartpole_env import CartpoleEnv <EOL> from rllab . envs . box2d . cartpole_swingup_env import CartpoleSwingupEnv <EOL> from rllab . envs . box2d . double_pendulum_env import DoublePendulumEnv <EOL> from rllab . envs . box2d . mountain_car_env import MountainCarEnv <EOL> from rllab . envs . grid_world_env import GridWorldEnv <EOL> from rllab . envs . identification_env import IdentificationEnv <EOL> import os <EOL> MUJOCO_ENABLED = True <EOL> try : <EOL> import rllab . mujoco_py <EOL> from rllab . envs . mujoco . half_cheetah_env import HalfCheetahEnv <EOL> from rllab . envs . mujoco . hopper_env import HopperEnv <EOL> from rllab . envs . mujoco . inverted_double_pendulum_env import InvertedDoublePendulumEnv <EOL> from rllab . envs . mujoco . point_env import PointEnv <EOL> from rllab . envs . mujoco . simple_humanoid_env import SimpleHumanoidEnv <EOL> from rllab . envs . mujoco . swimmer_env import SwimmerEnv <EOL> from rllab . envs . mujoco . walker2d_env import Walker2DEnv <EOL> from rllab . envs . mujoco . gather . point_gather_env import PointGatherEnv <EOL> from rllab . envs . mujoco . gather . swimmer_gather_env import SwimmerGatherEnv <EOL> from rllab . envs . mujoco . gather . ant_gather_env import AntGatherEnv <EOL> from rllab . envs . mujoco . maze . point_maze_env import PointMazeEnv <EOL> from rllab . envs . mujoco . maze . swimmer_maze_env import SwimmerMazeEnv <EOL> from rllab . envs . mujoco . maze . ant_maze_env import AntMazeEnv <EOL> except OSError : <EOL> print ( "<STR_LIT>" ) <EOL> MUJOCO_ENABLED = False <EOL> from rllab . envs . noisy_env import NoisyObservationEnv , DelayedActionEnv <EOL> from rllab . envs . normalized_env import NormalizedEnv <EOL> from rllab . envs . proxy_env import ProxyEnv <EOL> from rllab . envs . gym_env import GymEnv <EOL> simple_env_classes = [ <EOL> GridWorldEnv , <EOL> CartpoleEnv , <EOL> CarParkingEnv , <EOL> CartpoleSwingupEnv , <EOL> DoublePendulumEnv , <EOL> MountainCarEnv , <EOL> ] <EOL> if MUJOCO_ENABLED : <EOL> simple_env_classes . extend ( [ <EOL> PointEnv , <EOL> Walker2DEnv , <EOL> SwimmerEnv , <EOL> SimpleHumanoidEnv , <EOL> InvertedDoublePendulumEnv , <EOL> HopperEnv , <EOL> HalfCheetahEnv , <EOL> PointGatherEnv , <EOL> SwimmerGatherEnv , <EOL> AntGatherEnv , <EOL> PointMazeEnv , <EOL> SwimmerMazeEnv , <EOL> AntMazeEnv , <EOL> ] ) <EOL> envs = [ cls ( ) for cls in simple_env_classes ] <EOL> envs . append ( <EOL> ProxyEnv ( envs [ <NUM_LIT:0> ] ) <EOL> ) <EOL> envs . append ( <EOL> IdentificationEnv ( CartpoleEnv , { } ) <EOL> ) <EOL> envs . append ( <EOL> NoisyObservationEnv ( CartpoleEnv ( ) ) <EOL> ) <EOL> envs . append ( <EOL> DelayedActionEnv ( CartpoleEnv ( ) ) <EOL> ) <EOL> envs . append ( <EOL> NormalizedEnv ( CartpoleEnv ( ) ) <EOL> ) <EOL> envs . append ( <EOL> GymEnv ( '<STR_LIT>' ) <EOL> ) <EOL> @ tools . params ( * envs ) <EOL> def test_env ( env ) : <EOL> print "<STR_LIT>" , env . __class__ <EOL> ob_space = env . observation_space <EOL> act_space = env . action_space <EOL> ob = env . reset ( ) <EOL> assert ob_space . contains ( ob ) <EOL> a = act_space . sample ( ) <EOL> assert act_space . contains ( a ) <EOL> res = env . step ( a ) <EOL> assert ob_space . contains ( res . observation ) <EOL> assert np . isscalar ( res . reward ) <EOL> if '<STR_LIT>' in os . environ : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> env . render ( ) <EOL> env . terminate ( ) </s>
