Coverage for adaro_rl / zoo / HalfCheetah-v5 / environment.py: 77%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-14 07:50 +0000

1import numpy as np 

2 

3import gymnasium as gym 

4 

5from ..eval import custom_evaluate_policy 

6from ..environment import make_env 

7 

8 

9class EnvWrapper(gym.Wrapper): 

10 def __init__(self, env): 

11 super(EnvWrapper, self).__init__(env) 

12 

13 self.observation_perturbation_space = gym.spaces.Box( 

14 low=-self.observation_space.high, 

15 high=self.observation_space.high, 

16 dtype=np.float32, 

17 ) 

18 self.proportional_obs_perturbation_mask = np.zeros(self.observation_space.shape) 

19 

20 

21train_env_config = { 

22 "env_id": "HalfCheetah-v5", 

23 "wrapper_class": EnvWrapper, 

24 "n_envs": 1, 

25 "n_frame_stack": 1, 

26 "env_kwargs": {}, 

27} 

28 

29eval_env_config = { 

30 "env_id": "HalfCheetah-v5", 

31 "wrapper_class": EnvWrapper, 

32 "n_envs": 1, 

33 "n_frame_stack": 1, 

34 "env_kwargs": {}, 

35} 

36 

37render_env_config = { 

38 "env_id": "HalfCheetah-v5", 

39 "render_mode": "rgb_array", 

40 "wrapper_class": EnvWrapper, 

41 "n_envs": 1, 

42 "n_frame_stack": 1, 

43 "env_kwargs": {}, 

44} 

45 

46eval_config = { 

47 "evaluate_policy_fct": custom_evaluate_policy, 

48 "deterministic_eval": False, 

49}