Skip to content

Abstract Space

lerax.space.AbstractSpace

Bases: eqx.Module

Abstract base class for defining a space.

A space is a set of values that can be sampled from.

shape abstractmethod property

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

The shape of a sample of the space.

flat_size abstractmethod property

flat_size: int

Return the size of a flattened sample from the space.

sample abstractmethod

sample(
    *, key: Key, mask: MaskType | None = None
) -> SampleType

Returns a random sample from the space.

contains abstractmethod

contains(x: Any) -> Bool[Array, '']

Returns True if the input is in the space, False otherwise.

flatten_sample abstractmethod

flatten_sample(sample: SampleType) -> Float[Array, ' n']

Flatten a sample from the space into a 1-D array.

canonical abstractmethod

canonical() -> SampleType

Return an element of the space.

__eq__ abstractmethod

__eq__(other: object) -> bool

Return if this space is equal to another space.

__repr__ abstractmethod

__repr__() -> str

Return a string representation of the space.

__hash__ abstractmethod

__hash__() -> int

Return a hash of the space.

options: members: true