Skip to content

unienv_interface.space.spaces.dynamic_box

DynamicBoxSpace

DynamicBoxSpace(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], low: Union[int, float, BArrayType], high: Union[int, float, BArrayType], shape_low: Sequence[int], shape_high: Sequence[int], dtype: BDtypeType, device: Optional[BDeviceType] = None, fill_value: Union[int, float] = 0)

Bases: Space[BArrayType, BDeviceType, BDtypeType, BRNGType]

fill_value instance-attribute

fill_value = fill_value

shape_low property

shape_low: Tuple[int, ...]

Return the lower shape of the BoxSpace.

shape_high property

shape_high: Tuple[int, ...]

Return the upper shape of the BoxSpace.

backend instance-attribute

backend = backend

dtype instance-attribute

dtype = dtype

device property

device: Optional[_SpaceBDeviceT]

shape property

shape: tuple[int, ...] | None

Return the shape of the space as an immutable property.

pad_array_on_axis staticmethod

pad_array_on_axis(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], data: BArrayType, axis: int, target_size: int, fill_value: Union[int, float] = 0) -> BArrayType

get_array_axis_length staticmethod

get_array_axis_length(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], data: BArrayType, axis: int, fill_value: Union[int, float] = 0) -> int

unpad_array_on_axis staticmethod

unpad_array_on_axis(backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType], data: BArrayType, axis: int, fill_value: Union[int, float] = 0) -> BArrayType

get_low

get_low(shape: Sequence[int]) -> BArrayType

get_high

get_high(shape: Sequence[int]) -> BArrayType

to

to(backend: Optional[ComputeBackend] = None, device: Optional[Union[BDeviceType, Any]] = None) -> Union[DynamicBoxSpace[BArrayType, BDeviceType, BDtypeType, BRNGType], DynamicBoxSpace]

is_bounded

is_bounded(manner='both')

sample

sample(rng: BRNGType) -> Tuple[BRNGType, BArrayType]

Generates a single random sample inside the Box.

In creating a sample of the box, each coordinate is sampled (independently) from a distribution that is chosen according to the form of the interval:

  • :math:[a, b] : uniform distribution
  • :math:[a, \infty) : shifted exponential distribution
  • :math:(-\infty, b] : shifted negative exponential distribution
  • :math:(-\infty, \infty) : normal distribution

Returns:

Type Description
Tuple[BRNGType, BArrayType]

A sampled value from the Box

pad_data

pad_data(data: BArrayType, start_axis: Optional[int] = None, end_axis: Optional[int] = None) -> BArrayType

Pad the data to the maximum shape of this space.

unpad_data

unpad_data(data: BArrayType, start_axis: Optional[int] = None, end_axis: Optional[int] = None) -> BArrayType

Unpad the data to the minimum shape of this space.

create_empty

create_empty()

contains

contains(x: Any) -> bool

Return boolean specifying if x is a valid member of this space.

shape_contains

shape_contains(shape: Sequence[int]) -> bool

Check if the shape is within the bounds of this space.

clip

clip(x: BArrayType) -> BArrayType

Clip the values of x to be within the bounds of this space.

get_repr

get_repr(abbreviate: bool = False, include_backend: bool = True, include_device: bool = True, include_dtype: bool = True) -> str

data_to

data_to(data: BArrayType, backend: Optional[ComputeBackend] = None, device: Optional[Union[BDeviceType, Any]] = None) -> Union[BArrayType, Any]

Convert data to another backend.

abbr_device staticmethod

abbr_device(spaces: Iterable[Space[Any, _SpaceBDeviceT, _SpaceBDTypeT, _SpaceBDRNGT]]) -> Optional[_SpaceBDeviceT]

Return the shared device across spaces, or None if mixed/empty.