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).
has_inverse
instance-attribute
¶
has_inverse = all(t.has_inverse for t in _iter_leaves(transformations))
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
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.
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
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]]