Skip to content

unienv_interface.transformations.iter_transform

LeafwiseTransformation

LeafwiseTransformation(transformations: Union[DataTransformation, Mapping[str, Any], Tuple[Any, ...]])

Bases: DataTransformation

Apply a separate transformation to each leaf of a dict/tuple space.

transformations mirrors the space structure: a mapping for a DictSpace, a tuple for a TupleSpace and a DataTransformation for a leaf. This is what :meth:IterativeTransformation.direction_inverse returns when the leaves need different inverses (e.g. rescaling leaves with different source bounds).

transformations instance-attribute

transformations = transformations

has_inverse instance-attribute

has_inverse = all(t.has_inverse for t in _iter_leaves(transformations))

get_target_space_from_source

get_target_space_from_source(source_space)

transform

transform(source_space, data)

direction_inverse

direction_inverse(source_space=None) -> Optional[LeafwiseTransformation]

close

close()

serialize

serialize(source_space: Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]] = None) -> Dict[str, Any]

deserialize_from classmethod

deserialize_from(json_data: Dict[str, Any], source_space: Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]] = None) -> LeafwiseTransformation

IterativeTransformation

IterativeTransformation(transformation: DataTransformation, is_leaf_node_fn: Callable[[Space[Any, BDeviceType, BDtypeType, BRNGType]], bool] = default_is_leaf_fn, inv_is_leaf_node_fn: Callable[[Space[Any, BDeviceType, BDtypeType, BRNGType]], bool] = default_is_leaf_fn)

Bases: DataTransformation

transformation instance-attribute

transformation = transformation

is_leaf_node_fn instance-attribute

is_leaf_node_fn = is_leaf_node_fn

inv_is_leaf_node_fn instance-attribute

inv_is_leaf_node_fn = inv_is_leaf_node_fn

has_inverse instance-attribute

has_inverse = transformation.has_inverse

get_target_space_from_source

get_target_space_from_source(source_space: Space[Any, BDeviceType, BDtypeType, BRNGType])

transform

transform(source_space: Space, data: Union[Mapping[str, Any], BArrayType]) -> Union[Mapping[str, Any], BArrayType]

direction_inverse

direction_inverse(source_space=None) -> Optional[Union[IterativeTransformation, LeafwiseTransformation]]

Return the inverse transformation.

Inverses that depend on the source space (e.g. RescaleTransformation) are computed per leaf of source_space. When all leaves are equal a single IterativeTransformation is returned, otherwise a LeafwiseTransformation holding one inverse per leaf.

close

close()

serialize

serialize(source_space: Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]] = None) -> Dict[str, Any]

deserialize_from classmethod

deserialize_from(json_data: Dict[str, Any], source_space: Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]] = None) -> IterativeTransformation

default_is_leaf_fn

default_is_leaf_fn(space: Space[Any, BDeviceType, BDtypeType, BRNGType])

find_leaf_source_space

find_leaf_source_space(source_space: Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]], is_leaf_node_fn: Callable[[Space[Any, BDeviceType, BDtypeType, BRNGType]], bool]) -> Optional[Space[Any, BDeviceType, BDtypeType, BRNGType]]