Commit Graph

17 Commits

Author SHA1 Message Date
Markus Krimmel
745e7059e7 Pydocstyle spaces docstring (#2798)
* Added docstrings for spaces, WIP

* Formatting changes

* Use raw docstring for Box.sample

* Formatting fix

* Formatting fix

* Use :class:, :meth:, formatting fixes, resolve TODO, use Optional
2022-05-10 11:18:06 -04:00
Andrea PIERRÉ
06072ed2cb fix: type ignore from #2739 (#2744) 2022-04-11 13:27:23 -04:00
Gianluca De Cola
227e246ff6 Pyright versioning update. Fix #2700 (#2739)
* Moved pygame imports into render

* Formatting

* Make pygame optional for box2d, try to make formatting work

* fix tests, fix pre-commit.

* Update ci linter config.

* fix type hints for latest pyright version and backward compatibility with numpy <= 1.21.5

* pre-commit.

Co-authored-by: Ariel Kwiatkowski <ariel.j.kwiatkowski@gmail.com>
Co-authored-by: Gianluca De Cola <gianluca.decola@ags-it.com>
2022-04-07 21:19:52 -04:00
Manuel Goulão
658d4081c0 fix and complete docstrings to match the documentation page (#2697) 2022-04-06 15:12:55 -04:00
Andrea PIERRÉ
e913bc81b8 Improve pre-commit workflow (#2602)
* feat: add `isort` to `pre-commit`

* ci: skip `__init__.py` file for `isort`

* ci: make `isort` mandatory in lint pipeline

* docs: add a section on Git hooks

* ci: check isort diff

* fix: isort from master branch

* docs: add pre-commit badge

* ci: update black + bandit versions

* feat: add PR template

* refactor: PR template

* ci: remove bandit

* docs: add Black badge

* ci: try to remove all `|| true` statements

* ci: remove lint_python job

- Remove `lint_python` CI job
- Move `pyupgrade` job to `pre-commit` workflow

* fix: avoid messing with typing

* docs: add a note on running `pre-cpmmit` manually

* ci: apply `pre-commit` to the whole codebase
2022-03-31 15:50:38 -04:00
Tristan Deleu
e671aa168c Fix space utils for Discrete with non-zero start (#2645)
* Fix flatten utils to handle Discrete.start

* Fix vector space utils to handle Discrete.start

* More granular dispatch in vector utils

* Fix Box including the high end of the interval
2022-03-04 15:17:16 -05:00
Ilya Kamen
ad79b0ad0f typing in gym.spaces (#2541)
* typing in spaces.Box and spaces.Discrete

* adds typing to dict and tuple spaces

* Typecheck all spaces

* Explicit regex to include all files under space folder

* Style: use native types and __future__ annotations

* Allow only specific strings for Box.is_bounded args

* Add typing to changes from #2517

* Remove Literal as it's not supported by py3.7

* Use more recent version of pyright

* Avoid name clash for type checker

* Revert "Avoid name clash for type checker"

This reverts commit 1aaf3e0e0328171623a17a997b65fe734bc0afb1.

* Ignore the error. It's reported as probable bug at https://github.com/microsoft/pyright/issues/2852

* rebase and add typing for `_short_repr`
2022-01-24 17:22:11 -05:00
Rushiv Arora
fcbff7de12 Added singledispatch utility to vector.utils & changed order of space argument. (#2536)
* Fixed ordering of space. Added singledispatch utility.

* Added singledispatch utility to vector.utils & changed order of space argument

* Fixed Error from _BaseGymSpaces

* Minor adjustment for Discrete Spaces

* Fixed Tests/ to reflect changes

* Fixed precommit error - custom namespaces

* Concrete Implementations start with _
2022-01-21 11:28:34 -05:00
Elijah K
8e5ae02ab1 Py36+ syntax in gym/spaces: derived by running pyupgrade --py36-plus gym/spaces/**.py and flynt gym --ll 120 (#2466)
Co-authored-by: Ilya Kamen <ilya.kamenshchikov@bosch.com>
2021-11-14 08:50:23 -05:00
Tristan Deleu
be5e8c7fe4 Fix flatten utilities for spaces (#2328)
* Fix flatten utilities for spaces

* Revert changes to MultiBinary

* Factor out spaces in tests

* Add tests for flatten_space, flatten and unflatten
2021-08-21 18:04:09 -04:00
J K Terry
78d2b512d8 redo black (#2272) 2021-07-29 15:39:42 -04:00
Justin Terry
e9d2c41f2b redo black 2021-07-29 12:42:48 -04:00
Christian Clauss
bb81e141ea Blacken the codebase (#2265) 2021-07-28 20:26:34 -04:00
Melvin Wang
eee9b28882 Flattened space/point dtype mismatch (#2070)
* add test showing mismatch in flattened space dtype and flattened point dtype

* fix mismatch in flattened space dtype and flattened point dtype

* fix typo

* enhance test to detect when flattened dtype is incorrect

* fix incorrect flattened dtype

* remove inaccurate comment

* change flatten to always use space.dtype

* added testing for unflattened dtypes

* fix unflatten dtypes

* swtich flatten_space to use space.dtype for hardcoded space dtypes

* fix failure in python 3.5
2020-11-06 12:06:29 -08:00
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