Skip to content

unienv_data.batches.transformations

Classes:

Name Description
TransformedBatch

TransformedBatch

TransformedBatch(
    batch: BatchBase[
        SourceDataT, SourceBArrT, SourceBDeviceT, SourceBDTypeT, SourceBDRNGT
    ],
    transformation: DataTransformation,
    metadata_transformation: Optional[DataTransformation] = None,
)

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

Methods:

Name Description
get_flattened_at
get_flattened_at_with_metadata
set_flattened_at
extend_flattened
get_at
get_at_with_metadata
set_at
remove_at
extend
close

Release this view. The wrapped batch (and the transformation) 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.

get_column

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

Attributes:

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

batch instance-attribute

batch = batch

transformation instance-attribute

transformation = transformation

metadata_transformation instance-attribute

metadata_transformation = (
    metadata_transformation if self.batch.single_metadata_space is not None else None
)

backend property

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

device property

device: Optional[BDeviceType]

is_mutable property

is_mutable: bool

single_space instance-attribute

single_space = single_space

single_metadata_space instance-attribute

single_metadata_space = single_metadata_space

get_flattened_at

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

get_flattened_at_with_metadata

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

set_flattened_at

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

extend_flattened

extend_flattened(value: BArrayType) -> None

get_at

get_at(idx: Union[IndexableType, BArrayType] = None) -> BatchT

get_at_with_metadata

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

set_at

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

remove_at

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

extend

extend(value: BatchT) -> None

close

close()

Release this view. The wrapped batch (and the transformation) are not owned by the view and stay open; close them through whoever created it (BatchBase.__del__ calls close(), so closing the source here would tear it down whenever a view is garbage-collected).

append_flattened

append_flattened(value: BArrayType) -> None

Append one flattened sample to the batch.

append

append(value: BatchT) -> None

Append one structured 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.

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.