Skip to content

lit_sb3.wrappers.history

source module lit_sb3.wrappers.history

Classes

source class HistoryWrapper(env: gym.Env, horizon: int = 2)

Bases : gym.Wrapper[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

Stack past observations and actions to give a history to the agent.

:param env: Gym environment. :param horizon: Number of past steps to include in the observation.

Attributes

  • metadata : dict[str, Any] — attr:Env :attr:metadata.

  • render_mode : str | None — attr:Env :attr:render_mode.

  • spec : EnvSpec | None — attr:Env :attr:spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

  • action_space : spaces.Space[ActType] | spaces.Space[WrapperActType] — attr:Env :attr:action_space unless overwritten then the wrapper :attr:action_space is used.

  • observation_space : spaces.Space[ObsType] | spaces.Space[WrapperObsType] — attr:Env :attr:observation_space unless overwritten then the wrapper :attr:observation_space is used.

  • unwrapped : Env[ObsType, ActType] — Returns the base environment of the wrapper.

  • np_random_seed : int | None — attr:np_random_seed.

  • np_random : np.random.Generator — attr:Env :attr:np_random attribute.

Methods

source method HistoryWrapper.reset(seed: int | None = None, options: dict | None = None) → tuple[np.ndarray, dict]

source method HistoryWrapper.step(action: np.ndarray) → tuple[np.ndarray, SupportsFloat, bool, bool, dict]

source class HistoryWrapperObsDict(env: gym.Env, horizon: int = 2)

Bases : gym.Wrapper

History Wrapper for dict observation spaces.

:param env: Gym environment with a dict observation space. :param horizon: Number of past steps to include.

Attributes

  • metadata : dict[str, Any] — attr:Env :attr:metadata.

  • render_mode : str | None — attr:Env :attr:render_mode.

  • spec : EnvSpec | None — attr:Env :attr:spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

  • action_space : spaces.Space[ActType] | spaces.Space[WrapperActType] — attr:Env :attr:action_space unless overwritten then the wrapper :attr:action_space is used.

  • observation_space : spaces.Space[ObsType] | spaces.Space[WrapperObsType] — attr:Env :attr:observation_space unless overwritten then the wrapper :attr:observation_space is used.

  • unwrapped : Env[ObsType, ActType] — Returns the base environment of the wrapper.

  • np_random_seed : int | None — attr:np_random_seed.

  • np_random : np.random.Generator — attr:Env :attr:np_random attribute.

Methods

source method HistoryWrapperObsDict.reset(seed: int | None = None, options: dict | None = None) → tuple[dict[str, np.ndarray], dict]

source method HistoryWrapperObsDict.step(action: np.ndarray) → tuple[dict[str, np.ndarray], SupportsFloat, bool, bool, dict]