Commit Graph

106 Commits

Author SHA1 Message Date
Ariel Kwiatkowski
3fa10a2360 Fix return_info for wrappers (#2612)
* Fix `return_info` for Observation wrappers, Atari (?) and framestack

* Make type checkers and IDEs happier

* Merge in #2454

* Update the info dict based on no-op steps
Some type hints

* Bug fix

* Handle resets during frameskip
2022-02-17 12:03:35 -05:00
Markus
1400cfbcac Changed docstrings (#2611) 2022-02-12 19:39:03 -05:00
Ilya Kamen
2be9e60a4d Typecheck classic control environments (#2589)
* Typecheck classic control environments

* consistent imports + comments

* Don't use seed method

Although this code is exact duplication, we at least don't call deprecated method.

* Update core.py
2022-02-10 12:24:41 -05:00
John Balis
15049e22d7 Adding return_info argument to reset to allow for optional info dict as a second return value (#2546)
* initial draft of optional info dict in reset function, implemented for cartpole, tests seem to be passing

* merged core.py

* updated return type annotation for reset function in core.py

* optional metadata with return_info from reset added for all first party environments, with corresponding tests. Incomplete implementation for wrappers and vector wrappers

* removed Optional type for return_info arguments

* added tests for return_info to normalize wrapper and sync_vector_env

* autoformatted using black

* added optional reset metadata tests to several wrappers

* added return_info capability to async_vector_env.py and test to verify functionality

* added optional return_info test for record_video.py

* removed tests for mujoco environments

* autoformatted

* improved test coverage for optional reset return_info

* re-removed unit test envs accidentally reintroduced in merge

* removed unnecessary import

* changes based on code-review

* small fix to core wrapper typing and autoformatted record_epsisode_stats

* small change to pass flake8 style
2022-02-06 18:28:27 -05:00
Ilya Kamen
cf634bb444 Add typing to Wrapper signatures (#2590) 2022-02-05 11:25:47 -05:00
Ariel Kwiatkowski
925823661d Add options to the signature of env.reset (#2515)
* First find/replace, now tests

* Fixes to the vector env

* Make seed keyword only in wrappers

* (try to) fix the bug with old environments using new wrappers (with the seed keyword)

* black

* Change **kwargs to options, try to make it work; black

* Add OrderEnforcing wrapper to wrapper exports
Add a test for compatibility with old (pybullet-like) envs

* Add OrderEnforcing wrapper to wrapper exports
Add a test for compatibility with old (pybullet-like) envs
black

* Update the env checker

* Update the env checker

* Update the env checker to use inspect (might fail tests, let's see)

* Allow the signature to include kwargs in env_checker

* Minor fix
2022-01-19 17:28:59 -05:00
Ilya Kamen
65eeb73366 Typing/basics (#2529)
* Typing in gym/envs/registration.py

* Add registration to type checked list

* Adds type hints to space.py

* Typing in gym.core.Env

* Typing in seeding.py

* fixup Typing after rebase

* revert accidental change

* Install dependencies in pyright runner

* fix: can only install dependencies after checkout

* fix: install types in a venv

* fix path

* skip env activation, install directly from venv interpreter

* absolute path to venv

* use central python installation

* skip one more typecheck

* cleanup gh actions .yml

* Add py.typed to signal using sources for typechecking

* black!

Co-authored-by: sj_petterson <sj_petterson@gmail.com>
Co-authored-by: J K Terry <justinkterry@gmail.com>
2021-12-22 13:12:57 -05:00
Seungjae Ryan Lee
616b071158 Remove Robotics environments from Gym (#2516)
* Remove registration of Robotics envs

* Remove Robotics environments

* Update setup.py

* Update unit tests

* Remove unused GoalEnv class
2021-12-21 09:46:24 -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
Elijah K
a4da53c210 Py36+ syntax in gym/*.py: derived by running pyupgrade --py36-plus gym/*.py and flynt gym --ll 120 (#2473)
Co-authored-by: Ilya Kamen <ilya.kamenshchikov@bosch.com>
2021-11-14 08:50:40 -05:00
Tristan Deleu
d35d211fee Forward environment properties to the wrapper (#2373)
* Forward environment properties to the wrapper, fixes #2175

* Add tests for property forwarding in Wrapper

* Rename klass to class_ in test_core
2021-09-17 18:02:59 -04:00
Paweł Gajewski
ee0a568004 docstring fix for compute_reward (#2380) 2021-09-01 14:12:36 -04:00
J K Terry
267916b9d2 try removing dead code (#2305) 2021-08-10 10:50:59 -04:00
Justin Terry
ddd650a3fe black 2021-08-05 10:35:48 -04:00
Jakob Stigenberg
936dc6de36 mark abstract methods as abstract (#2158)
Co-authored-by: J K Terry <justinkterry@gmail.com>
2021-08-05 10:35:07 -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
Jim Turner
abb815c871 Clarify relationship between reset() and RNGs (#2019)
The current docstring for `reset()` seems to indicate that the
environment will be identical after separate calls to `reset()`.
However, the `reset()` function isn't supposed to reset the states of
the environment's RNGs [1]. This change clarifies the relationship
between the `reset()` function and the RNGs.

[1]: https://github.com/openai/gym/issues/250
2020-08-28 14:58:35 -07:00
Dan Timbrell
3bd5ef71c2 Clean some docstrings (#1854)
* add type of argument

* fix typos

* split lines for formatting

* reformat string, add ellipsis, remove r string

* make docstring stylistically consistent

* make docstrings a little more elaboratet

* reduce by 1 space

* make line wrap 120

* remove unnecessary line

* add returns to docstring

* add docstring, make code more pep8 and delete some unused print functions

* more pep8

* file docstring instead of comments

* delete unused variables, add file docstring and add some pep8 spring cleaning

* add file docstring, fix typos and add some pep8 correections

Co-authored-by: Dan <daniel.timbrell@ing.com>
2020-04-24 16:10:27 -05:00
Xingdong Zuo
0cd9266d98 Update core.py (#1627) 2019-10-25 15:48:21 -07:00
Kristian Hartikainen
a49c3e0fc8 Feature/pixel observation wrapper (#1499)
* Implement PixelObservationWrapper

* Change MujocoEnv.render to support custom camera_{name,id}

* Implement tests for PixelObservationWrapper

* Use env.get_pixels instead of direct env.render

* Fix camera_{id,name} check in pixel observation wrapper

* Fix rendering with explicit camera_id

* Add Wrapperget_pixels to allow call to be propagated to wrapped env

* Remove use of unnecessary `get_pixels` method

* Update PixelObservationWrapper to support multiple pixel keys

* Remove unnecessary `rgb_rendering_tracking` argument

* Remove rgb_rendering_tracking logic
2019-08-23 15:02:33 -07:00
pzhokhov
cd7f96e4db add spec property to wrapper to be forwarded to wrapped env. Fixes 1554 (#1574) 2019-06-28 15:27:43 -07:00
Christopher Hesse
cf06aeff9f docstring change, fixes #744 (#1493) 2019-05-24 14:29:01 -07:00
pzhokhov
5861d95ecd fix #1425 (#1459)
* fixes #1266

* test for correct observation space keys in GoalEnv

* fix import leading to test failures

* fix test failures
2019-05-10 15:00:01 -07:00
Xingdong Zuo
e801ccfdb0 [Update core.py] Remove underscore methods and its deprecation warning (#1320)
* Update core.py

* Update core.py

* Update core.py

* Update core.py

* Update core.py

* Update core.py
2019-05-03 14:53:31 -07:00
Yulun Li
3394e24572 Bugfix: wrapper should make spec optional for backward compatibility (#1424) 2019-04-08 19:29:13 -07:00
Xingdong Zuo
5744b25a6c [Update core.py]: support Wrapper for registering global methods with nested wrapping (#1347)
* Update core.py

* Update core.py
2019-03-25 12:11:53 -07:00
Xingdong Zuo
97a416fa14 [Update core.py] Remove unnecessary parts (#1406)
* Update core.py

* Update core.py
2019-03-25 10:23:14 -07:00
Sid Mysore
52e94a2b50 kwargs on reset for Reward and Action Wrapper (#1340) 2019-03-01 14:15:39 -08:00
Will Douglas
b5a3367fd5 Finish removing close as an option from render (#1009)
This cleans up some leftover changes after PR #836
2019-02-25 17:01:54 -07:00
Tom Alcorn
6c7e22245a Implement context handler protocol for Env (#1012)
This enables writing
```
import gym

with gym.make(...) as env:
    ...
```
without the need to remember to call `env.close()` later.
2019-02-25 16:53:58 -07:00
Xingdong Zuo
6497c9f1c6 Delete prng.py (#1196)
* Delete prng.py

Since it seems like this seeding function is rarely used.

* Update __init__.py

* Update kellycoinflip.py

* Update core.py

* Update box.py

* Update discrete.py

* Update multi_binary.py

* Update multi_discrete.py

* Update test_determinism.py

* Update test_determinism.py

* Update test_determinism.py

* Update core.py

* Update box.py

* Update test_determinism.py

* Update core.py

* Update box.py

* Update discrete.py

* Update multi_binary.py

* Update multi_discrete.py

* Update dict_space.py

* Update tuple_space.py

* Update core.py

* Create space.py

* Update __init__.py

* Update __init__.py

* Update box.py

* Update dict_space.py

* Update discrete.py

* Update dict_space.py

* Update multi_binary.py

* Update multi_discrete.py

* Update tuple_space.py

* Update discrete.py

* Update box.py

* Update dict_space.py

* Update multi_binary.py

* Update multi_discrete.py

* Update tuple_space.py

* Update multi_discrete.py

* Update multi_binary.py

* Update dict_space.py

* Update box.py

* Update test_determinism.py

* Update kellycoinflip.py

* Update space.py
2019-01-30 13:39:55 -08:00
Balázs Kossovics
e8349e3668 Fix in keyword with Spaces (#1261)
Binding `__contains__` to the Space class' contains method this way prevents overriding it in subclasses, which leads to `NotImplementedException`s when trying to do things like `2 in gym.spaces.Discrete(2)`.
2019-01-28 14:52:41 -08:00
Alok Singh
6332d4f113 rm unnecessary __contains__ duplicate code (#1147)
`contains` really should not exist when it does exactly what the builtin
magic method `__contains__` was meant for, but that would break backward
compatibility.
2018-08-28 10:51:28 -07:00
Alex Nichol
5404b39d06 remove double-wrap warning (#1061)
* remove double-wrap warning

* remove double-wrap tests
2018-06-04 17:00:27 -04:00
Adam Gleave
0e1fce13d2 Make Wrapper pass-through optional arguments to render (#1055) 2018-05-30 10:38:58 +02:00
Greg Brockman
28df2b1a21 Speed up time for import gym (#1020)
* Improve default import time from 750ms -> 73ms on 2016 Macbook pro

* Support code which expects gym.spaces.foo to work without a direct import of gym.spaces
2018-05-04 09:24:30 -07:00
Matthias Plappert
78c416ef7b New robotics environments (#912) 2018-02-26 17:35:07 +01:00
Glenn Powell
eeabe4f91f Reverting all commits to gym (#887) 2018-02-12 15:17:04 -08:00
Glenn Powell
148e2ec048 Generic interface to propagate custom commands through wrapper/env stack (#873)
* Spaces have a compatible method which determines if 2 Spaces are of the same shape, ignoring bounds.

* Added a command interface for Env/Wrappers

* Made command interface more aligned with gym codebase.  Added CommandWrapper helper class.

* Refactored method names from command to event/broadcast
2018-02-09 14:51:24 -08:00
Szymon Sidor
e775e5a333 add default arguments to gym.Spaces constructor for backwards compatibility 2018-02-08 16:46:25 -08:00
Glenn Powell
7682f7117f Glenn space compatibility (#872)
* Spaces have a compatible method which determines if 2 Spaces are of the same shape, ignoring bounds.

* Comparing compatibility of a Space with None will result in False now
2018-02-08 13:09:28 -08:00
Glenn Powell
2b2460b5c0 Spaces have a compatible method which determines if 2 Spaces are of the same shape, ignoring bounds. (#871) 2018-02-08 12:53:47 -08:00
John Schulman
4c460ba6c8 Cleanup, removal of unmaintained code (#836)
* add dtype to Box

* remove board_game, debugging, safety, parameter_tuning environments

* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder

* Improve render("human"), now resizable, closable window.

* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods

* CubeCrash unit test environment

* followup fixes

* MemorizeDigits unit test envrionment

* refactored spaces a bit
fixed indentation
disabled test_env_semantics

* fix unit tests

* fixes

* CubeCrash, MemorizeDigits tested

* gym backwards compatibility patch

* gym backwards compatibility, followup fixes

* changelist, add spaces to main namespaces

* undo_logger_setup for backwards compat

* remove configuration.py
2018-01-25 18:20:14 -08:00
John Schulman
dbae2538e8 only close env if it exists (otherwise we get bad stack traces when construction fails) 2017-09-02 18:10:50 -07:00
John Schulman
c13490db86 forward **reset through wrappers 2017-09-02 18:09:44 -07:00
John Schulman
2b30434d14 Make sure env.spec always exists and is valid. (#621)
* Make sure env.spec always exists and is valid. Previously there was an error when you tried to get the string representation of an unregistered env.

* update changelist
2017-06-16 16:35:03 -07:00
Trevor Blackwell
2a0a2a3a2b Forward spec down the tree, rather than copy at init time, since it can be set after wrapping 2017-03-09 18:16:26 -08:00
John Schulman
ed35158524 simplify renderer closing 2017-03-05 20:11:24 -08:00