unienv_data.batches.combined_batch¶
Classes:
| Name | Description |
|---|---|
CombinedBatch |
|
Functions:
| Name | Description |
|---|---|
convert_single_index_to_batch |
Convert a single index for this batch to a tuple of: |
convert_index_to_batch |
Convert an index for this batch to a tuple of: |
CombinedBatch
¶
CombinedBatch(
batches: Sequence[BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]],
device: Optional[BDeviceType] = None,
use_thread_pool: bool = False,
)
Bases: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]
Methods:
| Name | Description |
|---|---|
get_column |
Lazy view over one field of the samples that combines the children's column views, so |
get_flattened_at |
|
get_flattened_at_with_metadata |
|
get_at |
|
get_at_with_metadata |
|
set_flattened_at |
|
extend_flattened |
|
set_at |
|
remove_at |
|
extend |
|
close |
Release this view. The child batches are not owned by the view and stay open; |
append_flattened |
Append one flattened sample to the batch. |
append |
Append one structured sample to the batch. |
extend_from |
Copy data from another batch in bounded-size chunks. |
get_slice |
Create a lazy view over a subset of indices. |
Attributes:
| Name | Type | Description |
|---|---|---|
is_mutable |
|
|
batches |
|
|
use_thread_pool |
|
|
single_space |
|
|
single_metadata_space |
|
|
backend |
ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]
|
|
device |
Optional[BDeviceType]
|
|
get_column
¶
get_column(nested_keys: Sequence[Any]) -> BatchBase
Lazy view over one field of the samples that combines the children's column views, so
that children able to read a single column cheaply (replay buffers, stacked views, ...)
do so instead of fetching whole samples. Values, spaces, metadata and the flattened
layout are those of SubItemBatch(self, nested_keys), which is returned when the
children's column views cannot be combined. The view is read-only.
get_flattened_at_with_metadata
¶
get_flattened_at_with_metadata(
idx: Union[IndexableType, BaseException],
) -> Tuple[BArrayType, Dict[str, Any]]
get_at_with_metadata
¶
get_at_with_metadata(
idx: Union[IndexableType, BArrayType],
) -> Tuple[BatchT, Dict[str, Any]]
set_flattened_at
¶
set_flattened_at(idx: Union[IndexableType, BArrayType], value: BArrayType) -> None
close
¶
Release this view. The child batches are not owned by the view and stay open;
close them through whoever created it (BatchBase.__del__ calls close(), so
closing the children here would tear it down whenever a view is garbage-collected).
append_flattened
¶
Append one flattened sample to the batch.
extend_from
¶
extend_from(
other: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType],
chunk_size: int = 8,
tqdm: bool = False,
) -> None
Copy data from another batch in bounded-size chunks.
get_slice
¶
get_slice(
idx: Union[IndexableType, BArrayType],
) -> BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]
Create a lazy view over a subset of indices.
convert_single_index_to_batch
¶
convert_single_index_to_batch(
backend: ComputeBackend,
index_starts: BArrayType,
total_length: int,
idx: int,
device: Optional[BDeviceType] = None,
) -> Tuple[int, int]
Convert a single index for this batch to a tuple of
- The index of the batch
- The index to index into the batch
convert_index_to_batch
¶
convert_index_to_batch(
backend: ComputeBackend,
index_starts: BArrayType,
total_length: int,
idx: Union[IndexableType, BArrayType],
device: Optional[BDeviceType] = None,
) -> Tuple[int, Union[List[Tuple[int, BArrayType, BArrayType]], int]]
Convert an index for this batch to a tuple of
- The length of the resulting array
- List of tuples, each containing:
- The index of the batch
- The index to index into the batch
- The bool mask to index into the resulting array