Skip to content

unienv_interface.func_wrapper.transformation

Classes:

Name Description
FuncEnvCommonRenderInfo

Small metadata bundle returned by FuncEnv.render_init.

FuncEnvWrapper

Base wrapper for FuncEnv implementations.

FuncTransformWrapper

Attributes:

Name Type Description
WrapperBArrayT
WrapperContextT
WrapperObsT
WrapperActT
WrapperBDeviceT
WrapperBDtypeT
WrapperBRngT
WrapperRenderFrame
WrapperStateT
WrapperRenderStateT

WrapperBArrayT module-attribute

WrapperBArrayT = TypeVar('WrapperBArrayT')

WrapperContextT module-attribute

WrapperContextT = TypeVar('WrapperContextT')

WrapperObsT module-attribute

WrapperObsT = TypeVar('WrapperObsT')

WrapperActT module-attribute

WrapperActT = TypeVar('WrapperActT')

WrapperBDeviceT module-attribute

WrapperBDeviceT = TypeVar('WrapperBDeviceT')

WrapperBDtypeT module-attribute

WrapperBDtypeT = TypeVar('WrapperBDtypeT')

WrapperBRngT module-attribute

WrapperBRngT = TypeVar('WrapperBRngT')

WrapperRenderFrame module-attribute

WrapperRenderFrame = TypeVar('WrapperRenderFrame')

WrapperStateT module-attribute

WrapperStateT = TypeVar('WrapperStateT')

WrapperRenderStateT module-attribute

WrapperRenderStateT = TypeVar('WrapperRenderStateT')

FuncEnvCommonRenderInfo dataclass

FuncEnvCommonRenderInfo(
    render_mode: Optional[str] = None, render_fps: Optional[int] = None
)

Small metadata bundle returned by FuncEnv.render_init.

Attributes:

Name Type Description
render_mode Optional[str]
render_fps Optional[int]

render_mode class-attribute instance-attribute

render_mode: Optional[str] = None

render_fps class-attribute instance-attribute

render_fps: Optional[int] = None

FuncEnvWrapper

FuncEnvWrapper(
    func_env: FuncEnv[
        StateType,
        RenderStateType,
        BArrayType,
        ContextType,
        ObsType,
        ActType,
        RenderFrame,
        BDeviceType,
        BDtypeType,
        BRNGType,
    ],
)

Bases: Generic[WrapperStateT, WrapperRenderStateT, WrapperBArrayT, WrapperContextT, WrapperObsT, WrapperActT, WrapperRenderFrame, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT, StateType, RenderStateType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType], FuncEnv[WrapperStateT, WrapperRenderStateT, WrapperBArrayT, WrapperContextT, WrapperObsT, WrapperActT, WrapperRenderFrame, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT]

Base wrapper for FuncEnv implementations.

This mirrors :class:Wrapper but preserves the explicit state-passing style of the functional environment API.

Space-forwarding invariant

By default the wrapper forwards the wrapped FuncEnv's action_space, observation_space, and context_space unchanged. Because the :class:FuncEnv contract guarantees that these spaces already include the batch dimension when the env is batched, subclasses that override a space must ensure the replacement still matches the batching status of the underlying env. Never wrap an already-batched env space in an additional batch_space call.

Wrap a functional environment and optionally override its interface metadata.

Methods:

Name Description
update_observation_post_reset

Merge masked reset observations back into a full batched observation.

update_context_post_reset

Merge masked reset contexts back into a full batched context.

initial
reset
step
close
render_init
render_image
render_close
has_wrapper_attr

Checks if the attribute name exists in the environment.

get_wrapper_attr

Gets the attribute name from the environment.

set_wrapper_attr

Sets the attribute name on the environment with value.

Attributes:

Name Type Description
metadata Dict[str, Any]

Returns the :attr:Env :attr:metadata.

backend ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]
device Optional[WrapperBDeviceT]
batch_size Optional[int]
action_space Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]
observation_space Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]
context_space Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]
func_env
unwrapped FuncEnv
prev_wrapper_layer FuncEnv[StateType, RenderStateType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

metadata property writable

metadata: Dict[str, Any]

Returns the :attr:Env :attr:metadata.

backend property

backend: ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]

device property

device: Optional[WrapperBDeviceT]

batch_size property

batch_size: Optional[int]

action_space property writable

observation_space property writable

observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]

context_space property writable

context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]

func_env instance-attribute

func_env = func_env

unwrapped property

unwrapped: FuncEnv

prev_wrapper_layer property

prev_wrapper_layer: FuncEnv[
    StateType,
    RenderStateType,
    BArrayType,
    ContextType,
    ObsType,
    ActType,
    RenderFrame,
    BDeviceType,
    BDtypeType,
    BRNGType,
]

update_observation_post_reset

update_observation_post_reset(
    old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType
) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(
    old_context: ContextType, new_context: ContextType, mask: BArrayType
) -> ContextType

Merge masked reset contexts back into a full batched context.

initial

initial(
    *, seed: Optional[int] = None, **kwargs
) -> Tuple[WrapperStateT, WrapperContextT, WrapperObsT, Dict[str, Any]]

reset

reset(
    state: WrapperStateT,
    *args,
    seed: Optional[int] = None,
    mask: Optional[WrapperBArrayT] = None,
    **kwargs,
) -> Tuple[WrapperStateT, WrapperContextT, WrapperObsT, Dict[str, Any]]

step

step(
    state: WrapperStateT, action: WrapperActT
) -> Tuple[
    WrapperStateT,
    WrapperObsT,
    Union[SupportsFloat, WrapperBArrayT],
    Union[bool, WrapperBArrayT],
    Union[bool, WrapperBArrayT],
    Dict[str, Any],
]

close

close(state: WrapperStateT) -> None

render_init

render_init(
    state: WrapperStateT,
    *,
    seed: Optional[int] = None,
    render_mode: Optional[str] = None,
    **kwargs,
) -> Tuple[WrapperStateT, WrapperRenderStateT, FuncEnvCommonRenderInfo]

render_image

render_image(
    state: WrapperStateT, render_state: WrapperRenderStateT
) -> Tuple[
    WrapperRenderFrame | Sequence[WrapperRenderFrame] | None,
    WrapperStateT,
    WrapperRenderStateT,
]

render_close

render_close(state: WrapperStateT, render_state: WrapperRenderStateT) -> WrapperStateT

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the attribute name exists in the environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets the attribute name from the environment.

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets the attribute name on the environment with value.

FuncTransformWrapper

FuncTransformWrapper(
    func_env: FuncEnv[
        StateType,
        RenderStateType,
        BArrayType,
        ContextType,
        ObsType,
        ActType,
        RenderFrame,
        BDeviceType,
        BDtypeType,
        BRNGType,
    ],
    context_transformation: Optional[DataTransformation] = None,
    observation_transformation: Optional[DataTransformation] = None,
    action_transformation: Optional[DataTransformation] = None,
    target_action_space: Optional[
        Space[BArrayType, BDeviceType, BDtypeType, BRNGType]
    ] = None,
)

Bases: FuncEnvWrapper[StateType, RenderStateType, BArrayType, WrapperContextT, WrapperObsT, WrapperActT, WrapperRenderFrame, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT, StateType, RenderStateType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

Methods:

Name Description
set_action_transformation
initial
reset
step
close
render_init
render_image
render_close
update_observation_post_reset

Merge masked reset observations back into a full batched observation.

update_context_post_reset

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

Checks if the attribute name exists in the environment.

get_wrapper_attr

Gets the attribute name from the environment.

set_wrapper_attr

Sets the attribute name on the environment with value.

Attributes:

Name Type Description
context_transformation Optional[DataTransformation]
observation_transformation Optional[DataTransformation]
action_transformation Optional[DataTransformation]
metadata Dict[str, Any]

Returns the :attr:Env :attr:metadata.

backend ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]
device Optional[WrapperBDeviceT]
batch_size Optional[int]
observation_space Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]
action_space Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]
context_space Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]
unwrapped FuncEnv
prev_wrapper_layer FuncEnv[StateType, RenderStateType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
func_env

context_transformation property writable

context_transformation: Optional[DataTransformation]

observation_transformation property writable

observation_transformation: Optional[DataTransformation]

action_transformation property

action_transformation: Optional[DataTransformation]

metadata property writable

metadata: Dict[str, Any]

Returns the :attr:Env :attr:metadata.

backend property

backend: ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]

device property

device: Optional[WrapperBDeviceT]

batch_size property

batch_size: Optional[int]

observation_space property writable

observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]

action_space property writable

context_space property writable

context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]

unwrapped property

unwrapped: FuncEnv

prev_wrapper_layer property

prev_wrapper_layer: FuncEnv[
    StateType,
    RenderStateType,
    BArrayType,
    ContextType,
    ObsType,
    ActType,
    RenderFrame,
    BDeviceType,
    BDtypeType,
    BRNGType,
]

func_env instance-attribute

func_env = func_env

set_action_transformation

set_action_transformation(
    action_transformation: Optional[DataTransformation] = None,
    target_action_space: Optional[
        Space[BArrayType, BDeviceType, BDtypeType, BRNGType]
    ] = None,
) -> None

initial

initial(
    *, seed: Optional[int] = None, **kwargs
) -> Tuple[StateType, WrapperContextT, WrapperObsT, Dict[str, Any]]

reset

reset(
    state: StateType,
    *,
    seed: Optional[int] = None,
    mask: Optional[BArrayType] = None,
    **kwargs,
) -> Tuple[StateType, WrapperContextT, WrapperObsT, Dict[str, Any]]

step

step(
    state: StateType, action: WrapperActT
) -> Tuple[
    StateType,
    WrapperObsT,
    Union[SupportsFloat, WrapperBArrayT],
    Union[bool, WrapperBArrayT],
    Union[bool, WrapperBArrayT],
    Dict[str, Any],
]

close

close(state: WrapperStateT) -> None

render_init

render_init(
    state: WrapperStateT,
    *,
    seed: Optional[int] = None,
    render_mode: Optional[str] = None,
    **kwargs,
) -> Tuple[WrapperStateT, WrapperRenderStateT, FuncEnvCommonRenderInfo]

render_image

render_image(
    state: WrapperStateT, render_state: WrapperRenderStateT
) -> Tuple[
    WrapperRenderFrame | Sequence[WrapperRenderFrame] | None,
    WrapperStateT,
    WrapperRenderStateT,
]

render_close

render_close(state: WrapperStateT, render_state: WrapperRenderStateT) -> WrapperStateT

update_observation_post_reset

update_observation_post_reset(
    old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType
) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(
    old_context: ContextType, new_context: ContextType, mask: BArrayType
) -> ContextType

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the attribute name exists in the environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets the attribute name from the environment.

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets the attribute name on the environment with value.