gxm.wrappers.IgnoreTruncation#

class IgnoreTruncation(env, actions)#

Bases: Wrapper

A wrapper that treats truncation as termination and removes the corresponding obsercation from the timestep.

>>> import gxm
>>> from gxm.wrappers import IgnoreTruncation
>>> env = make("Gymnax/CartPole-v1")
>>> env = IgnoreTruncation(env)
__init__(env, actions)#
Parameters:

env (Environment) – The environment to wrap.

Methods

__init__(env, actions)

get_wrapper(wrapper_type)

Retrieve the first wrapper of a specific type from the environment.

has_wrapper(wrapper_type)

Check if the environment or any of its wrappers is of a specific type.

init(key)

Initialize the environment and return the initial state.

reset(key, env_state)

Reset the environment to its initial state.

step(key, env_state, action)

Perform a step in the environment given an action.

Attributes

unwrap

unwrapped

Retrieve the base environment by unwrapping all wrappers.

env

id

The unique identifier of the environment.

action_space

The action space of the environment.

observation_space

The observation space of the environment.

action_space: Space#

The action space of the environment.

env: Environment#
id: str#

The unique identifier of the environment.

init(key)#

Initialize the environment and return the initial state.

Parameters:

key (Array) – A JAX random key for any stochastic initialization.

Return type:

tuple[EnvironmentState, Timestep]

Returns:

A tuple containing the initial environment state and the initial timestep.

observation_space: Space#

The observation space of the environment.

reset(key, env_state)#

Reset the environment to its initial state.

Parameters:
  • key (Array) – A JAX random key for any stochasticity in the environment.

  • env_state (EnvironmentState) – The current state of the environment.

Return type:

tuple[EnvironmentState, Timestep]

Returns:

A tuple containing the reset environment state and the initial timestep.

step(key, env_state, action)#

Perform a step in the environment given an action.

Parameters:
  • key (Array) – A JAX random key for any stochasticity in the environment.

  • env_state (EnvironmentState) – The current state of the environment.

  • action (Array) – The action to take in the environment.

Return type:

tuple[EnvironmentState, Timestep]

Returns:

A tuple containing the new environment state and the resulting timestep.