schola.core.spaces.dict.DictSpace
- class schola.core.spaces.dict.DictSpace(space_dict=None)[source]
-
Bases:
Dict
A Space representing a dictionary of spaces.
- Parameters:
-
space_dict (Dict[str, gymnasium.spaces.Space]) – The dictionary of spaces to be represented.
- spaces
-
The dictionary of spaces represented by this object.
- Type:
-
Dict[str, gymnasium.spaces.Space]
See also
gymnasium.spaces.Dict
-
The gym space object that this class is analogous to.
proto_spaces.DictSpace
-
The protobuf representation of this space.
Methods
__init__
([space_dict])Constructor of
Dict
space.contains
(x)Return boolean specifying if x is a valid member of this space.
fill_proto
(msg, action)from_jsonable
(sample_n)Convert a JSONable data type to a batch of samples from this space.
from_proto
(message)get
(k[,d])items
()keys
()Returns the keys of the Dict.
process_data
(msg)sample
([mask])Generates a single random sample from this space.
seed
([seed])Seed the PRNG of this space and all subspaces.
simplify
()Simplify the dictionary space by merging subspaces of the same fundamental type, if possible.
to_jsonable
(sample_n)Convert a batch of samples from this space to a JSONable data type.
Normalize this dictionary space by normalizing all of the subspaces in this dictionary space.
values
()Attributes
Check if all the subspaces in the dictionary space are of the same fundamental type.
is_np_flattenable
Checks whether this space can be flattened to a
spaces.Box
.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.
Get the shapes of the subspaces in the dictionary space.
- __init__(space_dict=None)[source]
-
Constructor of
Dict
space.This space can be instantiated in one of two ways: Either you pass a dictionary of spaces to
__init__()
via thespaces
argument, or you pass the spaces as separate keyword arguments (where you will need to avoid the keysspaces
andseed
)- Parameters:
-
-
spaces – A dictionary of spaces. This specifies the structure of the
Dict
space -
seed – Optionally, you can use this argument to seed the RNGs of the spaces that make up the
Dict
space. -
**spaces_kwargs – If
spaces
isNone
, you need to pass the constituent spaces as keyword arguments, as described above.
-
- fill_proto(msg, action)[source]
-
- Parameters:
-
msg (DictPoint)
- classmethod from_proto(message)[source]
- property has_only_one_fundamental_type
-
Check if all the subspaces in the dictionary space are of the same fundamental type.
- Returns:
-
True if all the subspaces are of the same fundamental type, False otherwise
- Return type:
Examples
- process_data(msg)[source]
-
- Parameters:
-
msg (DictPoint)
- property shapes
-
Get the shapes of the subspaces in the dictionary space.
- Returns:
-
A dictionary of the shapes of the subspaces in the dictionary space
- Return type:
Examples
- simplify()[source]
-
Simplify the dictionary space by merging subspaces of the same fundamental type, if possible.
- Returns:
-
The simplified space
- Return type:
Examples