rlberry.spaces.Tuple¶
- class rlberry.spaces.Tuple(spaces)[source]¶
Bases:
TupleInherited from gymnasium.spaces.Tuple for compatibility with gym.
rlberry wraps gym.spaces to make sure the seeding mechanism is unified in the library (rlberry.seeding)
- Attributes:
- rngnumpy.random._generator.Generator
random number generator provided by rlberry.seeding
Methods
reseed()
get new random number generator
- count(value) integer -- return number of occurrences of value¶
- from_jsonable(sample_n: list[list[Any]]) list[tuple[Any, ...]][source]¶
Convert a JSONable data type to a batch of samples from this space.
- index(value[, start[, stop]]) integer -- return first index of value.¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- property is_np_flattenable¶
Checks whether this space can be flattened to a
spaces.Box.
- property np_random: Generator¶
Lazily seed the PRNG since this is expensive and only needed if sampling from this space.
As
seed()is not guaranteed to set the _np_random for particular seeds. We add a check afterseed()to set a new random number generator.
- sample(mask: tuple[Optional[Any], ...] | None = None) tuple[Any, ...][source]¶
Generates a single random sample inside this space.
This method draws independent samples from the subspaces.
- Args:
- mask: An optional tuple of optional masks for each of the subspace’s samples,
expects the same number of masks as spaces
- Returns:
Tuple of the subspace’s samples
- seed(seed: int | Sequence[int] | None = None) tuple[int, ...][source]¶
Seed the PRNG of this space and all subspaces.
Depending on the type of seed, the subspaces will be seeded differently
None- All the subspaces will use a random initial seedInt- The integer is used to seed theTuplespace that is used to generate seed values for each of the subspaces. Warning, this does not guarantee unique seeds for all the subspaces.List/Tuple- Values used to seed the subspaces. This allows the seeding of multiple composite subspaces[42, 54, ...].
- Args:
seed: An optional list of ints or int to seed the (sub-)spaces.
- Returns:
A tuple of the seed values for all subspaces
- property shape: tuple[int, ...] | None¶
Return the shape of the space as an immutable property.