stable_gym.common.max_episode_steps_injection_wrapper
This file contains a small gymnasium wrapper that injects the max_episode_steps argument of a potentially nested TimeLimit wrapper into the base environment under the _time_limit_max_episode_steps attribute.
Classes
A gymnasium wrapper that injects the |
Functions
Returns the |
|
|
Injects the |
Module Contents
- stable_gym.common.max_episode_steps_injection_wrapper.get_time_limit_wrapper_max_episode_steps(env)[source]
Returns the
max_episode_steps
attribute of a potentially nestedTimeLimit
wrapper.- Parameters:
env (gym.Env) – The gymnasium environment.
- Returns:
- The value of the
max_episode_steps
attribute of a potentially nested TimeLimit
wrapper. If the environment is not wrapped in aTimeLimit
wrapper, then this function returnsNone
.
- The value of the
- Return type:
- stable_gym.common.max_episode_steps_injection_wrapper.inject_attribute_into_base_env(env, attribute_name, attribute_value)[source]
Injects the
max_episode_steps
argument into the base environment under the _time_limit_max_episode_steps attribute.
- class stable_gym.common.max_episode_steps_injection_wrapper.MaxEpisodeStepsInjectionWrapper(env)[source]
Bases:
gymnasium.Wrapper
A gymnasium wrapper that injects the
max_episode_steps
attribute of theTimeLimit
wrapper into the base environment as the_time_limit_max_episode_steps
attribute. If the environment is not wrapped in aTimeLimit
wrapper, then the_time_limit_max_episode_steps
attribute is set toNone
.Wrap a gymnasium environment. :param env: The gymnasium environment. :type env: gym.Env