unienv_interface.wrapper.flatten¶
Classes:
| Name | Description |
|---|---|
FlattenActionWrapper |
|
FlattenContextObservationWrapper |
|
FlattenActionWrapper
¶
FlattenActionWrapper(
env: Env[
BArrayType,
ContextType,
ObsType,
ActType,
RenderFrame,
BDeviceType,
BDtypeType,
BRNGType,
],
)
Bases: ActionWrapper[BArrayType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
Methods:
| Name | Description |
|---|---|
map_action |
|
reverse_map_action |
|
step |
|
reset |
|
render |
|
close |
|
sample_space |
Sample from |
sample_action |
Sample one action from |
sample_observation |
Sample one observation from |
sample_context |
Sample one context value if |
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 given attribute is within the wrapper or its environment. |
get_wrapper_attr |
Gets an attribute from the wrapper and lower environments if |
set_wrapper_attr |
Sets an attribute on this wrapper or lower environment if |
Attributes:
| Name | Type | Description |
|---|---|---|
action_space |
|
|
metadata |
Dict[str, Any]
|
Returns the :attr: |
render_mode |
Optional[WrapperRenderFrame]
|
|
render_fps |
Optional[int]
|
|
backend |
ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]
|
|
device |
Optional[WrapperBDeviceT]
|
|
batch_size |
Optional[int]
|
|
observation_space |
Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]
|
|
context_space |
Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]
|
|
rng |
WrapperBRngT
|
Returns the :attr: |
unwrapped |
Env
|
Returns the base environment of the wrapper. |
prev_wrapper_layer |
Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
|
|
env |
|
action_space
instance-attribute
¶
action_space = space_flatten_utils.flatten_space(env.action_space)
observation_space
property
writable
¶
observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]
context_space
property
writable
¶
context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]
unwrapped
property
¶
unwrapped: Env
Returns the base environment of the wrapper.
This will be the bare :class:gymnasium.Env environment, underneath all layers of wrappers.
prev_wrapper_layer
property
¶
prev_wrapper_layer: Env[
BArrayType,
ContextType,
ObsType,
ActType,
RenderFrame,
BDeviceType,
BDtypeType,
BRNGType,
]
step
¶
step(
action: WrapperActT,
) -> Tuple[
ObsType,
Union[SupportsFloat, BArrayType],
Union[bool, BArrayType],
Union[bool, BArrayType],
Dict[str, Any],
]
reset
¶
reset(
*args, mask: Optional[WrapperBArrayT] = None, seed: Optional[int] = None, **kwargs
) -> Tuple[WrapperContextT, WrapperObsT, Dict[str, Any]]
sample_context
¶
sample_context() -> Optional[ContextType]
Sample one context value if context_space is defined.
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
¶
Checks if the given attribute is within the wrapper or its environment.
get_wrapper_attr
¶
Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The variable name to get |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The variable with name in wrapper or lower environments |
set_wrapper_attr
¶
Sets an attribute on this wrapper or lower environment if name is already defined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The variable name |
required |
value
|
Any
|
The new variable value |
required |
FlattenContextObservationWrapper
¶
FlattenContextObservationWrapper(
env: Env[
BArrayType,
ContextType,
ObsType,
ActType,
RenderFrame,
BDeviceType,
BDtypeType,
BRNGType,
],
flatten_context: bool = False,
flatten_observation: bool = True,
)
Bases: ContextObservationWrapper[Union[Any, BArrayType], Union[Any, BArrayType], BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
Methods:
| Name | Description |
|---|---|
map_context |
|
reverse_map_context |
|
map_observation |
|
reverse_map_observation |
|
step |
|
reset |
|
render |
|
close |
|
sample_space |
Sample from |
sample_action |
Sample one action from |
sample_observation |
Sample one observation from |
sample_context |
Sample one context value if |
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 given attribute is within the wrapper or its environment. |
get_wrapper_attr |
Gets an attribute from the wrapper and lower environments if |
set_wrapper_attr |
Sets an attribute on this wrapper or lower environment if |
Attributes:
| Name | Type | Description |
|---|---|---|
context_space |
|
|
observation_space |
|
|
flatten_context |
|
|
flatten_observation |
|
|
metadata |
Dict[str, Any]
|
Returns the :attr: |
render_mode |
Optional[WrapperRenderFrame]
|
|
render_fps |
Optional[int]
|
|
backend |
ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]
|
|
device |
Optional[WrapperBDeviceT]
|
|
batch_size |
Optional[int]
|
|
action_space |
Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]
|
|
rng |
WrapperBRngT
|
Returns the :attr: |
unwrapped |
Env
|
Returns the base environment of the wrapper. |
prev_wrapper_layer |
Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
|
|
env |
|
context_space
instance-attribute
¶
context_space = space_flatten_utils.flatten_space(env.context_space)
observation_space
instance-attribute
¶
observation_space = space_flatten_utils.flatten_space(env.observation_space)
action_space
property
writable
¶
action_space: Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]
unwrapped
property
¶
unwrapped: Env
Returns the base environment of the wrapper.
This will be the bare :class:gymnasium.Env environment, underneath all layers of wrappers.
prev_wrapper_layer
property
¶
prev_wrapper_layer: Env[
BArrayType,
ContextType,
ObsType,
ActType,
RenderFrame,
BDeviceType,
BDtypeType,
BRNGType,
]
step
¶
step(
action: ActType,
) -> Tuple[
WrapperObsT,
Union[float, BArrayType],
Union[bool, BArrayType],
Union[bool, BArrayType],
Dict[str, Any],
]
reset
¶
reset(
*args, mask: Optional[BArrayType] = None, seed: Optional[int] = None, **kwargs
) -> Tuple[WrapperContextT, WrapperObsT, Dict[str, Any]]
sample_context
¶
sample_context() -> Optional[ContextType]
Sample one context value if context_space is defined.
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
¶
Checks if the given attribute is within the wrapper or its environment.
get_wrapper_attr
¶
Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The variable name to get |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The variable with name in wrapper or lower environments |
set_wrapper_attr
¶
Sets an attribute on this wrapper or lower environment if name is already defined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The variable name |
required |
value
|
Any
|
The new variable value |
required |