pymgrid.utils.space.ModuleSpace#

class pymgrid.utils.space.ModuleSpace(unnormalized_low, unnormalized_high, shape=None, dtype=<class 'numpy.float64'>, seed=None)[source]#

A space with both normalized and unnormalized versions.

Both normalized and unormalized versions are of type gym.spaces.Box.

This object also handles conversion of values from normalized to unnormalized and vice-versa.

Parameters#

unnormalized_lowfloat or array-like

Lower bound of the space.

unnormalized_highfloat or array-like

Upper bound of the space.

shapetuple or None, default None

Shape of the space. If None, shape is inferred from unnormalized_low and unnormalized_high.

dtypenp.dtype, default np.float64

dtype of the action space.

seedint or None, default None

Random seed.

Warning

This parameter will be ignored if earlier versions of gym are installed.

Methods

contains(x)

Check if x is a valid member of the space.

denormalize(val)

from_jsonable(sample_n)

Convert a JSONable data type to a batch of samples from this space.

normalize(val)

sample([normalized])

Randomly sample an element of this space.

seed([seed])

Seed the PRNG of this space and possibly the PRNGs of subspaces.

to_jsonable(sample_n)

Convert a batch of samples from this space to a JSONable data type.

Attributes

is_np_flattenable

Checks whether this space can be flattened to a spaces.Box.

normalized

np_random

Lazily seed the PRNG since this is expensive and only needed if sampling from this space.

shape

Return the shape of the space as an immutable property.

unnormalized