unienv_interface.space.space_utils¶
reshape_batch_size
¶
reshape_batch_size(space: Space, old_batch_shape: Tuple[int], new_batch_shape: Tuple[int]) -> Space
reshape_batch_size_in_data
¶
reshape_batch_size_in_data(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], data: Any, old_batch_shape: Tuple[int], new_batch_shape: Tuple[int]) -> Any
swap_batch_dims_in_data
¶
swap_batch_dims_in_data(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], data: Any, dim1: int, dim2: int) -> Any
batch_differing_spaces
¶
batch_differing_spaces(spaces: Sequence[Space], device: Optional[Any] = None) -> Space
construct_space_from_data_stream
¶
construct_space_from_data_stream(data: Iterable[Any], backend: ComputeBackend, add_bounds: bool = True) -> Space
Construct a space from a stream of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Iterable[Any]
|
An iterable stream of data samples. |
required |
backend
|
ComputeBackend
|
The compute backend to use for array operations. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Space |
Space
|
The constructed space. |
construct_space_from_data
¶
construct_space_from_data(data: Any, backend: ComputeBackend, candidate_space: Optional[Space] = None, add_bounds: bool = False) -> Space
space_to_json
¶
space_to_json(space: Space) -> typing.Dict[str, Any]
Serialize a Space to a JSON-compatible dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
Space
|
The space to serialize. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Any]
|
A JSON-compatible representation of the space. |
json_to_space
¶
json_to_space(json_data: Dict[str, Any], map_backend: ComputeBackend, map_device: Optional[BDeviceType]) -> Space
Deserialize a JSON-compatible dictionary into a Space instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
dict
|
JSON-compatible space payload produced by
:func: |
required |
map_backend
|
ComputeBackend
|
Backend used to reconstruct backend-owned arrays and dtypes in the returned space. |
required |
map_device
|
Optional[BDeviceType]
|
Optional device on which to place backend arrays created during deserialization. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Space |
Space
|
The deserialized space. |