Skip to content

unienv_data.batches.subitem_batch

Classes:

Name Description
SubItemBatch

A batch that offers a view of the original batch with a fixed index.

Functions:

Name Description
recursive_index

SubItemBatch

SubItemBatch(
    batch: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType],
    sub_indexes: Sequence[Any],
)

Bases: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]

A batch that offers a view of the original batch with a fixed index. This is a read-only batch, since it is a view of the original batch. If you want to change the data, you should mutate the containing batch instead.

Methods:

Name Description
get_at
get_at_with_metadata
close
get_flattened_at

Fetch samples as flattened backend arrays.

get_flattened_at_with_metadata

Fetch flattened samples together with optional per-sample metadata.

set_flattened_at

Overwrite existing samples using flattened data.

append_flattened

Append one flattened sample to the batch.

extend_flattened

Append a batched block of flattened samples.

set_at

Overwrite existing samples using structured data.

remove_at

Remove one or more samples from the batch.

append

Append one structured sample to the batch.

extend

Append a batched block of structured samples.

extend_from

Copy data from another batch in bounded-size chunks.

get_slice

Create a lazy view over a subset of indices.

get_column

Create a lazy view over a nested field inside each sample.

Attributes:

Name Type Description
is_mutable
batch
sub_indexes
backend ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]
device Optional[BDeviceType]
single_space
single_metadata_space

is_mutable class-attribute instance-attribute

is_mutable = False

batch instance-attribute

batch = batch

sub_indexes instance-attribute

sub_indexes = sub_indexes

backend property

backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]

device property

device: Optional[BDeviceType]

single_space instance-attribute

single_space = single_space

single_metadata_space instance-attribute

single_metadata_space = single_metadata_space

get_at

get_at(idx)

get_at_with_metadata

get_at_with_metadata(idx) -> Tuple[BatchT, Dict[str, Any]]

close

close() -> None

get_flattened_at

get_flattened_at(idx: Union[IndexableType, BArrayType]) -> BArrayType

Fetch samples as flattened backend arrays.

get_flattened_at_with_metadata

get_flattened_at_with_metadata(
    idx: Union[IndexableType, BArrayType],
) -> Tuple[BArrayType, Optional[Dict[str, Any]]]

Fetch flattened samples together with optional per-sample metadata.

set_flattened_at

set_flattened_at(idx: Union[IndexableType, BArrayType], value: BArrayType) -> None

Overwrite existing samples using flattened data.

append_flattened

append_flattened(value: BArrayType) -> None

Append one flattened sample to the batch.

extend_flattened

extend_flattened(value: BArrayType) -> None

Append a batched block of flattened samples.

set_at

set_at(idx: Union[IndexableType, BArrayType], value: BatchT) -> None

Overwrite existing samples using structured data.

remove_at

remove_at(idx: Union[IndexableType, BArrayType]) -> None

Remove one or more samples from the batch.

append

append(value: BatchT) -> None

Append one structured sample to the batch.

extend

extend(value: BatchT) -> None

Append a batched block of structured samples.

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.

get_column

get_column(
    nested_keys: Sequence[str],
) -> BatchBase[Any, BArrayType, BDeviceType, BDtypeType, BRNGType]

Create a lazy view over a nested field inside each sample.

recursive_index

recursive_index(
    space_or_data: Union[BatchT, Space], index: Sequence[Any]
) -> Union[BatchT, Space]