Commit Graph

1 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