Commit Graph

13 Commits

Author SHA1 Message Date
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
Alexis DUBURCQ
108f32c743 gym.spaces.Tuple inherits from collections.abc.Sequence (#2637)
* gym.spaces.Tuple inherits from collections.abc.Sequence

Following the PR I did a few months back (https://github.com/openai/gym/pull/2446), the tuple wrapper of gym should inherits from the abstract interface of Python. It is important for type check via `isinstance` and enable using such objects transparently with libraries such as [dmtree](https://github.com/deepmind/tree). 

It will bring a way helper methods along the way but it cannot be avoided to interoperability: : `__iter__`, `__reversed__`, `index`, and `count`
Personally I don't think it is an issue since it is new features and it is not conflicting.

As the previous PR, this patch is NOT removing any existing feature and should not break backward compatibility.

* Add unit test

* Fix unit tests

* Final fix.

* Remove irrelevant comment.

* Fix black formatter.
2022-03-04 10:25:19 -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
Xuehai Pan
18c8b988d4 Type cast in spaces families (#2491)
* Type cast for `spaces.Dict`

* Type cast for `spaces.Tuple`

* Type cast for `spaces.Discrete`

* Type cast for `spaces.MultiDiscrete`

* Type cast for `spaces.MultiBinary`
2021-12-16 00:45:37 -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
RaghuSpaceRajan
c571b0d853 Make Tuple and Dicts be seedable with lists and dicts of seeds + make the seed in default initialization controllable (#1774)
* Make the seed in default initialization controllable

Since seed() is being called in default initialization of Space, it should be controllable for reproducibility.

* Updated derived classes of Space to have their seeds controllable at initialization.

* Allow Tuple's spaces to each have their own seed

* Added dict based seeding for Dict space; test cases for Tuple and Dict seeding

* Update discrete.py

* Update test_spaces.py

* Add seed to __init__()

* blacked

* Fix black

* Fix failing tests
2021-09-13 14:08:01 -04:00
Xuehai Pan
bb8e8063e9 Fix seed method for spaces.Tuple and spaces.Dict (#2365)
* Fix seed method for Tuple and Dict

* Improve stochasticity

* Update test cases for seed method

* Update test cases for seed method

Update test cases for seed method

Update test cases for seed method
2021-09-02 10:15:34 -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
pzhokhov
9a7f10ece1 fix accidental seed function overriding in Space (#1506)
* fix accidental seed function overriding in Space

* default seed to None in spaces
2019-05-24 18:16:07 -07:00
Xingdong Zuo
f408e2284c Rename tuple_space.py to tuple.py 2019-03-25 00:56:57 +01:00