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.
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
- class rlmesh.spaces.SpaceBridge[source]¶
Bases:
Generic[OutputT]Convert space samples and inputs for a Python backend.
- __init__(sample, input=None)[source]¶
- Parameters:
sample (Callable[[object, SpaceSpec], OutputT])
input (Callable[[object, SpaceSpec], object] | None)
- Return type:
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
- rlmesh.spaces.space_from_spec(spec: SpaceSpec, *, bridge: None = None) Space[Value][source]¶
- rlmesh.spaces.space_from_spec(spec: SpaceSpec, *, bridge: SpaceBridge[OutputT]) Space[OutputT]
Create the named RLMesh space wrapper for a native spec.
- Parameters:
spec (SpaceSpec) – Native space specification.
bridge (SpaceBridge[OutputT] | None) – Optional backend bridge for sample/contains values.
- Returns:
Matching RLMesh space wrapper.
- Return type:
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 | SpaceSpec)
high (float | None)
shape (Sequence[int] | None)
dtype (str)
- 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 (str)
- 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 (str)
- 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