Commit Graph

59 Commits

Author SHA1 Message Date
John Balis
3a8daafce1 Removing return_info argument to env.reset() and deprecated env.seed() function (reset now always returns info) (#2962)
* removed return_info, made info dict mandatory in reset

* tenatively removed deprecated seed api for environments

* added more info type checks to wrapper tests

* formatting/style compliance

* addressed some comments

* polish to address review

* fixed tests after merge, and added a test of the return_info deprecation assertion if found in reset signature

* some organization of env_checker tests, reverted a probably merge error

* added deprecation check for seed function in env

* updated docstring

* removed debug prints, tweaked test_check_seed_deprecation

* changed return_info deprecation check from assertion to warning

* fixes to vector envs, now  should be correctly structured

* added some explanation and typehints for mockup depcreated return info reset function

* re-removed seed function from vector envs

* added explanation to _reset_return_info_type and changed the return statement
2022-08-23 11:09:54 -04:00
Omar Younis
de9eed541b Remove old Render API (#3027)
* init

* add .gitignore

* fix .gitignore

* remove internal backend use

* fix VideoRecorder test

* fix .gitignore

* fix order enforcing tests

* adapt play.py

* reformat

* fix .gitignore

* add type to DummyPlayEnv
2022-08-22 11:21:08 -04:00
Mark Towers
8b744130bc Fixed all environment close issues in testing (#3020) 2022-08-08 17:41:15 -04:00
Arjun KG
907b1b20dd New Step API with terminated, truncated bools instead of done (#2752) 2022-07-09 16:48:06 -04:00
Pablo Samuel Castro
ca39816943 Add reset params (with np support) (#2926) 2022-07-06 07:08:01 -04:00
Ariel Kwiatkowski
51a6386a6b Revert "Parameterize initial state distributions for classic control envs. (#2921)" (#2923)
This reverts commit af918d81e0.
2022-06-23 18:21:37 -04:00
Pablo Samuel Castro
af918d81e0 Parameterize initial state distributions for classic control envs. (#2921) 2022-06-23 17:06:04 -04:00
Omar Younis
f2aeb823f7 check render_mode in make (#2896) 2022-06-16 12:29:44 -04:00
Omar Younis
9acf9cd367 Render API (#2671)
* add pygame GUI for frozen_lake.py env

* add new line at EOF

* pre-commit reformat

* improve graphics

* new images and dynamic window size

* darker tile borders and fix ICC profile

* pre-commit hook

* adjust elf and stool size

* Update frozen_lake.py

* reformat

* fix #2600

* #2600

* add rgb_array support

* reformat

* test render api change on FrozenLake

* add render support for reset on frozenlake

* add clock on pygame render

* new render api for blackjack

* new render api for cliffwalking

* new render api for Env class

* update reset method, lunar and Env

* fix wrapper

* fix reset lunar

* new render api for box2d envs

* new render api for mujoco envs

* fix bug

* new render api for classic control envs

* fix tests

* add render_mode None for CartPole

* new render api for test fake envs

* pre-commit hook

* fix FrozenLake

* fix FrozenLake

* more render_mode to super - frozenlake

* remove kwargs from frozen_lake new

* pre-commit hook

* add deprecated render method

* add backwards compatibility

* fix test

* add _render

* move pygame.init() (avoid pygame dependency on init)

* fix pygame dependencies

* remove collect_render() maintain multi-behaviours .render()

* add type hints

* fix renderer

* don't call .render() with None

* improve docstring

* add single_rgb_array to all envs

* remove None from metadata["render_modes"]

* add type hints to test_env_checkers

* fix lint

* add comments to renderer

* add comments to single_depth_array and single_state_pixels

* reformat

* add deprecation warnings and env.render_mode declaration

* fix lint

* reformat

* fix tests

* add docs

* fix car racing determinism

* remove warning test envs, customizable modes on renderer

* remove commments and add todo for env_checker

* fix car racing

* replace render mode check with assert

* update new mujoco

* reformat

* reformat

* change metaclass definition

* fix tests

* implement mark suggestions (test, docs, sets)

* check_render

Co-authored-by: J K Terry <jkterry0@gmail.com>
2022-06-07 18:20:56 -04:00
J K Terry
6744d53aec remove unuseful comments 2022-06-06 09:04:16 -04:00
Mark Towers
273e3f22ce Updated docstrings using darglint (#2827)
* Updated docstrings using darglint, ignoring 402 and 202 plus shortened lines into multiple where they were overflowing

* Remove abstract method decorators, for a future PR

* Add __future__ import annotation for python 3.7+ notion

* Added missing bracket

* Fix minor docstring tables
2022-05-25 09:46:41 -04:00
Mark Towers
e2266025e6 Pydocstyle utils vector docstring (#2788)
* Added pydocstyle to pre-commit

* Added docstrings for tests and updated the tests for autoreset

* Add pydocstyle exclude folder to allow slowly adding new docstrings

* Add docstrings for setup.py and gym/__init__.py, core.py, error.py and logger.py

* Check that all unwrapped environment are of a particular wrapper type

* Reverted back to import gym.spaces.Space to gym.spaces

* Fixed the __init__.py docstring

* Fixed autoreset autoreset test

* Updated gym __init__.py top docstring

* Fix examples in docstrings

* Add docstrings and type hints where known to all functions and classes in gym/utils and gym/vector

* Remove unnecessary import

* Removed "unused error" and make APIerror deprecated at gym 1.0

* Add pydocstyle description to CONTRIBUTING.md

* Added docstrings section to CONTRIBUTING.md

* Added :meth: and :attr: keywords to docstrings

* Added :meth: and :attr: keywords to docstrings

* Imported annotations from __future__ to fix python 3.7

* Add __future__ import annotations for python 3.7

* isort

* Remove utils and vectors for this PR and spaces for previous PR

* Update gym/envs/classic_control/acrobot.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/envs/classic_control/acrobot.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/envs/classic_control/acrobot.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/spaces/dict.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/env_checker.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/env_checker.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/env_checker.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/env_checker.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/env_checker.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/ezpickle.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/ezpickle.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Update gym/utils/play.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Pre-commit

* Updated docstrings with :meth:

* Updated docstrings with :meth:

* Update gym/utils/play.py

* Update gym/utils/play.py

* Update gym/utils/play.py

* Apply suggestions from code review

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* pre-commit

* Update gym/utils/play.py

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Updated fps and zoom parameter docstring

* Update play docstring

* Apply suggestions from code review

Added suggested corrections from @markus28

Co-authored-by: Markus Krimmel <montcyril@gmail.com>

* Pre-commit magic

* Update the `gym.make` docstring with a warning for `env_checker`

* Updated and fixed vector docstrings

* Update test names for reflect the project filename style

Co-authored-by: Markus Krimmel <montcyril@gmail.com>
2022-05-20 09:49:30 -04:00
Mark Towers
b704d4660e Place try except around all imports of pygame (#2782)
* Place try except around all imports for pygame and optional modules in box2d, classic_control and toy_text

* Updated all ImportErrors to DependencyNotInstalled

* Re-add comment on why pygame is imported
2022-04-29 19:44:28 -04:00
Mark Towers
bf093c6890 Update the flake8 pre-commit ignores (#2778)
* Remove additional ignores from flake8

* Remove all unused imports

* Remove all unused imports

* Update flake8 and pyupgrade

* F841, removed unused variables

* E731, removed lambda assignment to variables

* Remove E731, F403, F405, F524

* Remove E722, bare exceptions

* Remove E712, compare variable == True or == False to is True or is False

* Remove E402, module level import not at top of file

* Added --pre-file-ignores

* Add --per-file-ignores removing E741, E302 and E704

* Add E741, do not use variables named ‘l’, ‘O’, or ‘I’ to ignore issues in classic control

* Fixed issues for pytest==6.2

* Remove unnecessary # noqa

* Edit comment with the removal of E302

* Added warnings and declared module, attr for pyright type hinting

* Remove unused import

* Removed flake8 E302

* Updated flake8 from 3.9.2 to 4.0.1

* Remove unused variable
2022-04-26 11:18:37 -04:00
trigaten
752af3c57d Fix black version (#2724)
* isort

* update pre commit
2022-04-01 09:01:34 -04:00
Ariel Kwiatkowski
bc17d9f7e7 Make pygame optional in classic control and toy text envs (#2712)
* Moved pygame imports into render

* Formatting
2022-03-31 18:55:48 -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
Andrew Tan Jin Shen
6f1ec7cc1b Fix issues with pygame event handling (#2684)
* Fix issues with pygame event handling

* Fix display initialization and exit for jupyter
2022-03-11 11:37:04 -05:00
Markus
8d4dff1b66 Locked framerate in human-mode rendering with PyGame (#2649)
* Locked framerate in human-mode rendering for box2d and classic_control

* Fixed pyright errors

* Use the new metadata key for FPS, add toytext environments
2022-03-02 10:37:48 -05:00
trigaten
35b78ac0ab Rename render modes/fps (#2654)
* Update pendulum.py

* version warnings

* black

* try except

* update notices version

* Exception

* nosec

* black

* no loop, stderr

* black

* convert ## to ###

* correct subheader

* black

* despace

* spacing

* frozen lake fixes

* rename render modes/fps

* fix API test

* fix API test

* fix more API tests

* black

* add render fps
2022-02-28 15:54:03 -05:00
Rushiv Arora
649a245465 Fixed tests and precommit (#2653) 2022-02-28 08:54:16 -05:00
trigaten
b5c0cd2894 ## to ### (#2623)
* Update pendulum.py

* version warnings

* black

* try except

* update notices version

* Exception

* nosec

* black

* no loop, stderr

* black

* convert ## to ###

* correct subheader

* black

* despace

* spacing
2022-02-17 19:43:36 -05:00
Andrew Tan Jin Shen
6eba48db95 Refactor classic control rendering to use pygame (#2599)
* refactor classic control rendering to use pygame

* Rebase from upstream

* Revert deletion from rebasing

* Remove pyglet
2022-02-11 10:48:42 -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
trigaten
b9e8b6c587 Reformat some docstrings, remove unneeded image links (#2578)
* docs+credits

* docs: refactor box2d + comment version history

* fix mujoco line lengths

* fix more env line lengths

* black

* typos

* put docstrings in base environments rather than highest version

* fix richer reacher

* black

* correct black version

* continuous mountain car docstring to markdown

* remove unneeded images

* black

Co-authored-by: Andrea PIERRÉ <andrea_pierre@brown.edu>
2022-01-27 15:36:50 -05:00
trigaten
a149869bcb docs+credits (#2574)
* docs+credits

* docs: refactor box2d + comment version history

* fix mujoco line lengths

* fix more env line lengths

* black

* typos

Co-authored-by: Andrea PIERRÉ <andrea_pierre@brown.edu>
2022-01-26 16:02:42 -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
Carlos Luis
8a96440084 Move rendering.py to utils (#2551)
* Move rendering.py to utils

* Rename rendering.py to pyglet_rendering.py
2022-01-06 13:01:29 -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
J K Terry
8ad5b016e9 docs typo 2021-10-23 05:58:33 -04:00
J K Terry
2bd436bf53 black 2021-08-26 15:38:23 -04:00
Ariel Kwiatkowski
bbb3072f38 Update acrobot docstrings (#2362)
Removed time from the signature of derivs in the documentation. Also fixed a typo and removed an example that's no longer valid
2021-08-26 15:37:56 -04:00
J K Terry
5af9104e09 fix black 2021-08-26 15:17:57 -04:00
TuckerBMorgan
cce192762c Changes to acrbot making more readable (#2130)
Co-authored-by: marsmute <marsmute@protonmail.com>
2021-08-26 15:17:36 -04:00
Ariel Kwiatkowski
d7023500f3 Fix dtypes to be consistent with observation_space (#2340)
* Changed the dtypes of classic control envs to float32

* Fixed formatting via black

* Added dtype tests

* Formatting, and test error message

* Only test dtypes for Box space

* Fix Bipedal Walker and Car Racing

* Undo the car racing dtype change

* Redo the car racing dtype change - set to np.float32, and updated observation_space to reflect it
2021-08-21 18:11:19 -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
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
a14e1c7292 Fix unnecessary warnings (#1800)
* Update pendulum.py

* Update continuous_mountain_car.py

* Update cartpole.py

* Update mujoco_env.py

* Update mountain_car.py

* Update acrobot.py
2020-02-29 01:11:29 +01:00
Julien Jerphanion
5ea025d87d Replace np.cos, np.sin, np.pi for readability (#1733)
Remove the `np.` prefix as those two functions and this constant are imported directly.
2019-11-08 14:22:50 -08:00
Abhinav Sagar
13f32c7689 Update acrobot.py 2019-06-14 14:29:03 -07:00
Arash Rowshan
f0909baaf7 corrects typo in AcrobotEnv description (#1272) 2019-02-08 16:37:37 -08:00
Antonin RAFFIN
cdd212db4b Fix autodetect dtype warnings (#1234)
* Fix autodetect dtype warnings

* Use warnings module for gym logger

* Fix warning in tests
2018-11-28 17:27:27 -08:00
Charles Packer
094e6b8e6a CartPole/Acrobot rendering fix (#1189)
* Fixed rendering to properly display modifications to length etc

* 'self.length is half the pole's length'

* Explicitly base viewer size on Acrobot link size

* Made correct polygon rendering work for different link lengths
2018-10-18 14:30:18 -07:00
cfperez
243226bee0 Fix env.close() to allow re-opening window (#1155) 2018-09-14 13:36:57 -07:00
4d55397500
16c35274dc unused local variable acrobot (#900) 2018-02-27 10:18:07 -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
Florentin Hennecker
88ca75b945 Fix acrobot doc (#608)
* [fix] acrobot documentation on state was wrong

* [fix] acrobot doc typos
2017-06-14 13:27:21 -07:00