Spaces¶
RLMesh spaces are Python wrappers around native SpaceSpec values. They provide the familiar sample, contains, and seed methods while keeping the spec available for transport and conversion.
You rarely build one directly: a client or contract hands you the wrapper through observation_space and action_space. Reach for the conversion helpers below when you need to bridge to or from a Gymnasium space, and see Gymnasium Compatibility for the per-space mapping.
Base Types¶
- class rlmesh.spaces.Space[source]¶
Bases:
Generic[OutputT]Base wrapper for an RLMesh-native space.
- seed(seed=None)[source]¶
Seed the native sampler for this space.
- Parameters:
seed (int | None)
- Return type:
int | None
Conversion Helpers¶
- rlmesh.spaces.from_gymnasium_space(space)[source]¶
Convert a Gymnasium space into an RLMesh space wrapper.
- Parameters:
space (object) – Gymnasium or legacy Gym space.
- Returns:
Matching RLMesh space wrapper.
- Return type:
Space[Value]
- rlmesh.spaces.to_gymnasium_space(space)[source]¶
Convert an RLMesh space or native spec into a Gymnasium space.
- Parameters:
space (Space[Any] | SpaceSpec) – RLMesh space wrapper or native space specification.
- Returns:
Gymnasium space object.
- Return type:
object
Fundamental Spaces¶
Box and Discrete are stable. MultiBinary, MultiDiscrete, and Text are experimental and may change; see Compatibility and the per-space labels in Gymnasium Compatibility.
- final class rlmesh.spaces.Box[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Continuous box space.
- Parameters:
low – Lower bound, or an existing native
SpaceSpec.high – Upper bound when constructing a new spec.
shape – Box shape when constructing a new spec.
dtype – Element dtype name.
- __init__(low, high=None, shape=None, dtype='float32')[source]¶
- Parameters:
low (float | Literal['inf', '-inf'] | ~rlmesh._rlmesh.SpaceSpec)
high (float | Literal['inf', '-inf'] | None)
shape (Sequence[int] | None)
dtype (Literal['float16', 'float32', 'float64'] | object)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
- final class rlmesh.spaces.Discrete[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Discrete integer space.
- Parameters:
n – Number of values, or an existing native
SpaceSpec.start – First integer value in the space.
dtype – Integer dtype name.
- __init__(n, start=0, dtype='int64')[source]¶
- Parameters:
n (int | SpaceSpec)
start (int)
dtype (Literal['int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64'] | object)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
- final class rlmesh.spaces.MultiBinary[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Binary vector or tensor space.
- Parameters:
shape – Number of binary values, tensor shape, or native
SpaceSpec.
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
- final class rlmesh.spaces.MultiDiscrete[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Vector of discrete dimensions.
- Parameters:
nvec – Per-dimension counts, or an existing native
SpaceSpec.dtype – Integer dtype name.
- __init__(nvec, dtype='int64')[source]¶
- Parameters:
nvec (Sequence[int] | SpaceSpec)
dtype (Literal['int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64'] | object)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
- final class rlmesh.spaces.Text[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Bounded text space.
- Parameters:
max_length – Maximum string length, or an existing native
SpaceSpec.min_length – Minimum string length.
charset – Optional allowed character set.
- __init__(max_length, min_length=1, charset=None)[source]¶
- Parameters:
max_length (int | SpaceSpec)
min_length (int)
charset (str | None)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
Composite Spaces¶
Dict is stable. Tuple is experimental and may change; see Compatibility and the per-space labels in Gymnasium Compatibility.
- final class rlmesh.spaces.Tuple[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Ordered tuple of child spaces.
- Parameters:
spaces – Iterable of child spaces, or an existing native
SpaceSpec.
- __init__(spaces)[source]¶
- Parameters:
spaces (Iterable[Space[Any] | SpaceSpec] | SpaceSpec)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool
- final class rlmesh.spaces.Dict[source]¶
Bases:
Space[None|bool|int|float|str|bytes|_Tensor|list[Value] |tuple[Value, …] |dict[str, Value]]Mapping of named child spaces.
Exposes read-only mapping access over its children, mirroring
gymnasium.spaces.Dict: index a child by name (space["obs"]), iterate names (for name in space), test membership ("obs" in space), takelen(space), and readkeys()/values()/items(). The children are immutable (aMappingProxyType); build a newDictto change them.- Parameters:
spaces – Mapping of child spaces, or an existing native
SpaceSpec.
- __init__(spaces)[source]¶
- Parameters:
spaces (Mapping[str, Space[Any] | SpaceSpec] | SpaceSpec)
- Return type:
None
- contains(value)[source]¶
Return whether a value is contained in this space.
- Parameters:
value (object)
- Return type:
bool