Commit Graph

3 Commits

Author SHA1 Message Date
troiganto
a8d08c041d Improve observation space of FlattenObservation wrapper (#1884)
* Add tests for gym.spaces.utils.

* Add docstrings to gym.spaces.utils.

* Remove some trailing whitespace.

* Add gym.spaces.utils.flatten_space.

The new function also is reexported as gym.spaces.flatten_space. It
improves the determination of observation_space in
gym.wrappers.FlattenObservation.

* Produce OrderedDict instead of dict in gym.spaces.unflatten().

`gym.spaces.Dict` is very particular about producing its samples as
`OrderedDict` in order preserve the order of its items. Hence,
`unflatten()` should reproduce this behavior.

* In test_utils.compare_nested, also verify order of OrderedDict items.

* Add examples to flatten_space() docstring.

* Document ``flatten(space, space.sample()) in flatten_space(space)``.

Co-authored-by: Nico Madysa <nico.madysa@tu-dresden.de>
2020-05-08 14:19:55 -07:00
Zach Dwiel
3ee7e678bf Respect the order of keys in a Dict's observation space when flattening (#1748)
* Respect the order of keys in a Dict's observation space when flattening

Prior to this change, the order of the key/values in the observation was used instead of the order in the Dict's observation space. unflatten already uses the order specified by the Dict's observation space.

* add tests for FlattenObservation
2019-12-06 15:49:56 +01:00
Xingdong Zuo
5efcd86b36 [Update space]: support flat_dim, flatten, unflatten (fixes #1310) (#1319)
* Update space.py

* Update box.py

* Update discrete.py

* Update tuple_space.py

* Update box.py

* Update box.py

* Update discrete.py

* Update space.py

* Update box.py

* Update discrete.py

* Update tuple_space.py

* Update multi_binary.py

* Update multi_discrete.py

* Update and rename dict_space.py to dict.py

* Update tuple_space.py

* Rename tuple_space.py to tuple.py

* Update __init__.py

* Update multi_binary.py

* Update multi_discrete.py

* Update space.py

* Update box.py

* Update discrete.py

* Update multi_binary.py

* Update multi_discrete.py

* Update __init__.py

* Update __init__.py

* Update multi_discrete.py

* Update __init__.py

* Update box.py

* Update box.py

* Update multi_discrete.py

* Update discrete.py

* Update multi_discrete.py

* Update discrete.py

* Update dict.py

* Update dict.py

* Update multi_binary.py

* Update multi_discrete.py

* Update tuple.py

* Update discrete.py

* Update __init__.py

* Update box.py

* Update and rename dict.py to dict_space.py

* Update dict_space.py

* Update dict_space.py

* Update dict_space.py

* Update discrete.py

* Update multi_binary.py

* Create utils.py

* Update __init__.py

* Update multi_discrete.py

* Update multi_discrete.py

* Update space.py

* Update and rename tuple.py to tuple_space.py
2019-03-24 11:29:43 -07:00