* 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
* Add a case for the Box shape where the low and high values are both scalars
* Add seeding.RandomNumberGenerator parameter to Dict seed. Modify __repr__ for the dictionary space string looks similar to an actual dictionary
* Add seeding.RandomNumberGenerator parameter to Multi Binary seed
* Add seeding.RandomNumberGenerator parameter to Multi Binary seed. Modify nvec typing to include np.ndarray
* Space seed typing can be a seeding.RandomNumberGenerator. If a seeding.RNG is provided then it is assigned to _np_random and .seed is not run
* Fixed the tuple seeding type as List[int] is not a valid Space seed type
* Added typing to batch_space. The batch_space seed is equal to the space's seeding
* Fixed the seeding type
* Add test for batch space seeds are identical to the original space's seeding
* Add equivalence function for RandomNumberGenerator comparing the bit_generator.state
* The batch_space functions uses a copy of the seed for the original space
* Set the action space seed for sync_vector_env seed testing
* Add test for the seeding of the sync vector environment
* Update the test_batch_space_seed to check the resulting sampling are equivalent for testing
* Revert representation back to the original version
* Remove additional Box shape initialisation
* Remove additional typing of MultiDiscrete
* Fixed bug of Space batch space where the original space's np_random is not a complete copy of the original space
* Add CustomSpace to the batched space seed test
* Modify the CustomSpace sample to produce a random number not a static value
* Fix CustomSpace to reflect the sample function
* Copy the space.np_random for the batched_space seed to ensure that the original space doesn't sampling doesn't effect the batched_space
* Parameterized the batch_space_seed, added testing for rng_different_at_each_index and test_deterministic
* Black and isort pre-commit changes
* Pre-commit fix
* MacOS, test_read_from_shared_memory throws an error that the inner _process_write function was unpicklable. Making the function a top-level function solves this error
* Fixed typing of seed where a space's seed function differs from Space.seed's typing
* Added check that the sample lengths are equal and explicitly provided the number of batched spaces n=1
* Removed relative imports for absolute imports
* Use deepcopy instead of copy
* Replaces `from numpy.testing._private.utils import assert_array_equal` with `from numpy.testing import assert_array_equal`
* Using the seeding `__eq__` function, replace `np_random.bit_generator.state` with `np_random`
* Added docstrings and comments to the tests to explain their purpose
* Remove __eq__ from RandomNumberGenerator and add to tests/vector/utils
* Add sync vector determinism test for issue #2680
* Fixed bug for 462101d384 (r850740825)
* Made the new seeds a list of integers
* 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>
* 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.
* 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`
* 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`
* 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
* 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