Spaces

JAX-compatible action and observation spaces.

JAX-compatible action and observation space classes.

Derived from JaxMARL: https://github.com/FLAIROx/JaxMARL/blob/main/jaxmarl/environments/spaces.py

class f1tenth_gym_jax.envs.spaces.Space

Bases: object

Minimal abstract base class for JAX-compatible spaces.

sample(rng)
Parameters:

rng (Array)

Return type:

Array | ndarray | bool | number

contains(x)
Parameters:

x (int64)

Return type:

bool

class f1tenth_gym_jax.envs.spaces.Discrete(num_categories, dtype=<class 'jax.numpy.int32'>)

Bases: Space

Minimal JAX-compatible discrete space.

Parameters:

num_categories (int)

sample(rng)

Sample random action uniformly from set of categorical choices.

Parameters:

rng (Array)

Return type:

Array | ndarray | bool | number

contains(x)

Check whether specific object is within space.

Parameters:

x (int64)

Return type:

bool

class f1tenth_gym_jax.envs.spaces.MultiDiscrete(num_categories, dtype=<class 'jax.numpy.int32'>)

Bases: Space

Minimal JAX-compatible multi-discrete space.

Parameters:

num_categories (Sequence[int])

sample(rng)

Sample random action uniformly from set of categorical choices.

Parameters:

rng (Array)

Return type:

Array | ndarray | bool | number

contains(x)

Check whether specific object is within space.

Parameters:

x (int64)

Return type:

bool

class f1tenth_gym_jax.envs.spaces.Box(low, high, shape, dtype=<class 'jax.numpy.float32'>)

Bases: Space

Minimal JAX-compatible array-shaped box space.

Parameters:
  • low (float)

  • high (float)

  • shape (Tuple[int])

  • dtype (dtype)

sample(rng)

Sample a random value, supporting bounded and unbounded dimensions.

Parameters:

rng (Array)

Return type:

Array | ndarray | bool | number

contains(x)

Check whether specific object is within space.

Parameters:

x (int64)

Return type:

bool

class f1tenth_gym_jax.envs.spaces.Dict(spaces)

Bases: Space

Minimal JAX-compatible dictionary of simpler spaces.

Parameters:

spaces (dict)

sample(rng)

Sample random action from all subspaces.

Parameters:

rng (Array)

Return type:

dict

contains(x)

Check whether dimensions of object are within subspace.

Parameters:

x (int64)

Return type:

bool

class f1tenth_gym_jax.envs.spaces.Tuple(spaces)

Bases: Space

Minimal JAX-compatible tuple product of simpler spaces.

Parameters:

spaces (tuple | list)

sample(rng)

Sample random action from all subspaces.

Parameters:

rng (Array)

Return type:

Tuple[Array | ndarray | bool | number]

contains(x)

Check whether dimensions of object are within subspace.

Parameters:

x (int64)

Return type:

bool