Commit Graph

23 Commits

Author SHA1 Message Date
Tristan Deleu
cdb72ea552 Fix close_extras not implemented by default in VectorEnv (#2507) 2021-12-08 19:55:09 -05:00
Ariel Kwiatkowski
c364506710 Seeding update (#2422)
* Ditch most of the seeding.py and replace np_random with the numpy default_rng. Let's see if tests pass

* Updated a bunch of RNG calls from the RandomState API to Generator API

* black; didn't expect that, did ya?

* Undo a typo

* blaaack

* More typo fixes

* Fixed setting/getting state in multidiscrete spaces

* Fix typo, fix a test to work with the new sampling

* Correctly (?) pass the randomly generated seed if np_random is called with None as seed

* Convert the Discrete sample to a python int (as opposed to np.int64)

* Remove some redundant imports

* First version of the compatibility layer for old-style RNG. Mainly to trigger tests.

* Removed redundant f-strings

* Style fixes, removing unused imports

* Try to make tests pass by removing atari from the dockerfile

* Try to make tests pass by removing atari from the setup

* Try to make tests pass by removing atari from the setup

* Try to make tests pass by removing atari from the setup

* First attempt at deprecating `env.seed` and supporting `env.reset(seed=seed)` instead. Tests should hopefully pass but throw up a million warnings.

* black; didn't expect that, didya?

* Rename the reset parameter in VecEnvs back to `seed`

* Updated tests to use the new seeding method

* Removed a bunch of old `seed` calls.

Fixed a bug in AsyncVectorEnv

* Stop Discrete envs from doing part of the setup (and using the randomness) in init (as opposed to reset)

* Add explicit seed to wrappers reset

* Remove an accidental return

* Re-add some legacy functions with a warning.

* Use deprecation instead of regular warnings for the newly deprecated methods/functions
2021-12-08 16:14:15 -05:00
Tristan Deleu
01cc8a3a16 Add documentation for Vectorized environments (#2327) 2021-11-14 08:59:04 -05:00
Costa Huang
778d3c2473 [gym.vector]: add terminal_observation to info (#2484)
* [gym.vector]: add `terminal_observation` to `info`

* add test cases

* quick format fix
2021-11-14 08:57:44 -05:00
Elijah K
cb79c763bb Py36+ syntax in gym/vector: derived by running pyupgrade --py36-plus gym/vector/**.py and flynt gym --ll 120 (#2474)
Co-authored-by: Ilya Kamen <ilya.kamenshchikov@bosch.com>
2021-11-14 08:51:32 -05:00
Xingdong Zuo
263a3419ef [Python 3]: replace time() with perf_counter() for better measurements of short duration. (#2385)
* Update record_episode_statistics.py

* Update stats_recorder.py

* Update async_vector_env.py
2021-09-11 13:03:54 -04:00
Costa Huang
2853ce4797 Add RecordVideo wrapper (#2300)
* Add RecordVideo wrapper

* bug fix

* don't change gym's core API

* add test cases

* reformat
2021-08-18 16:36:40 -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
Tristan Deleu
58401db97e Allow custom spaces in VectorEnv (#2038)
* Allow custom observation spaces in VectorEnv

* Replace np.copy by deepcopy in reset of SyncVectorEnv

* Add tests for VectorEnv with custom spaces

* Add tests for shared memory and batches of custom spaces

* Remove unused import in VectorEnv test

* Add warning note in the Space class for custom spaces
2020-09-21 13:38:51 -07:00
Tristan Deleu
1a92bc6c83 Remove Python 2 compatibility in VectorEnv (#2034) 2020-09-11 15:07:27 -07:00
Christian Clauss
b7bd6bd1cc Typo: enviroment --> environment (#1828)
* Typo: enviroment --> environment

* Typo: information does not have a plural form in English
2020-03-06 16:37:23 -05:00
Xingdong Zuo
fe244fadf6 [gym.vector]: a genericclose with user-defined close_extras (#1631)
* Update vector_env.py

* Update sync_vector_env.py

* Update async_vector_env.py

* Update vector_env.py

* Update async_vector_env.py
2019-10-25 15:18:54 -07:00
pzhokhov
51136b1290 vector env updates (#1706)
* make daemon=True an option of async_vector_env

* custom worker in async_vector_env

* add compatibility methods to SyncVectorEnv

* fix name in sync_vector_env

* vectorenv api cleanup

* add docstrings for daemon and worker options in AsyncVectorEnv
2019-10-09 15:08:10 -07:00
Tristan Deleu
50ef7bf199 Fix AsyncVectorEnv with spawn context and shared memory (Fixes #1542) 2019-07-12 14:44:25 -07:00
Tristan Deleu
6ffcd212df Check for closed pipes in close for AsyncVectorEnv 2019-06-28 16:30:53 -07:00
Tristan Deleu
316156903d Check if the pipe is not None is _poll (Fixes #1542) 2019-06-28 16:30:53 -07:00
Tristan Deleu
cab1d0ec38 Add success flag in results from workers in AsyncVectorEnv 2019-06-28 16:30:53 -07:00
Tristan Deleu
ad8b3b20e6 Move _raise_if_errors after recv in AsyncVectorEnv (Fixes #1546) 2019-06-28 16:30:53 -07:00
Tristan Deleu
2e56028e9a Handle KeyboardInterrupt exception in AsyncVectorEnv (Fixes #1543) 2019-06-28 15:00:49 -07:00
Tristan Deleu
02cff040ee Fix typo in AsyncVectorEnv (Fixes #1544) 2019-06-28 14:42:11 -07:00
Tristan Deleu
c6a97e17ee Vectorized environments (#1513)
* Initial version of vectorized environments

* Raise an exception in the main process if child process raises an exception

* Add list of exposed functions in vector module

* Use deepcopy instead of np.copy

* Add documentation for vector utils

* Add tests for copy in AsyncVectorEnv

* Add example in documentation for batch_space

* Add cloudpickle dependency in setup.py

* Fix __del__ in VectorEnv

* Check if all observation spaces are equal in AsyncVectorEnv

* Check if all observation spaces are equal in SyncVectorEnv

* Fix spaces non equality in SyncVectorEnv for Python 2

* Handle None parameter in create_empty_array

* Fix check_observation_space with spaces equality

* Raise an exception when operations are out of order in AsyncVectorEnv

* Add version requirement for cloudpickle

* Use a state instead of binary flags in AsyncVectorEnv

* Use numpy.zeros when initializing observations in vectorized environments

* Remove poll from public API in AsyncVectorEnv

* Remove close_extras from VectorEnv

* Add test between AsyncVectorEnv and SyncVectorEnv

* Remove close in check_observation_space

* Add documentation for seed and close

* Refactor exceptions for AsyncVectorEnv

* Close pipes if the environment raises an error

* Add tests for out of order operations

* Change default argument in create_empty_array to np.zeros

* Add get_attr and set_attr methods to VectorEnv

* Improve consistency in SyncVectorEnv
2019-06-21 14:29:44 -07:00