mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-07-31 05:44:31 +00:00
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
This commit is contained in:
45
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
45
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
## Type of change
|
||||
|
||||
Please delete options that are not relevant.
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] This change requires a documentation update
|
||||
|
||||
### Screenshots
|
||||
Please attach before and after screenshots of the change if applicable.
|
||||
|
||||
<!--
|
||||
Example:
|
||||
|
||||
| Before | After |
|
||||
| ------ | ----- |
|
||||
| _gif/png before_ | _gif/png after_ |
|
||||
|
||||
|
||||
To upload images to a PR -- simply drag and drop an image while in edit mode and it should upload the image directly. You can then paste that source into the above before/after sections.
|
||||
-->
|
||||
|
||||
# Checklist:
|
||||
|
||||
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with `pre-commit run --all-files` (see `CONTRIBUTING.md` instructions to set it up)
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
|
||||
<!--
|
||||
As you go through the checklist above, you can mark something as done by putting an x character in it
|
||||
|
||||
For example,
|
||||
- [x] I have done this task
|
||||
- [ ] I have not done this task
|
||||
-->
|
17
.github/workflows/lint_python.yml
vendored
17
.github/workflows/lint_python.yml
vendored
@@ -1,25 +1,14 @@
|
||||
---
|
||||
name: lint_python
|
||||
on: [pull_request, push]
|
||||
jobs:
|
||||
lint_python:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: pip install isort pytest pyupgrade safety
|
||||
- run: isort --check-only --profile black . || true
|
||||
- run: pip install -e .[nomujoco]
|
||||
- run: pytest . || true
|
||||
- run: pytest --doctest-modules . || true
|
||||
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
|
||||
|
||||
pyright:
|
||||
name: Check types with pyright
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-platform: [ "Linux" ]
|
||||
python-version: [ "3.7"]
|
||||
python-platform: ["Linux"]
|
||||
python-version: ["3.7"]
|
||||
fail-fast: false
|
||||
env:
|
||||
PYRIGHT_VERSION: 1.1.204
|
||||
|
@@ -1,15 +1,7 @@
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/PyCQA/bandit/
|
||||
rev: 1.7.0
|
||||
hooks:
|
||||
- id: bandit
|
||||
args:
|
||||
- --recursive
|
||||
- --skip
|
||||
- B101,B108,B301,B403,B404,B603
|
||||
- .
|
||||
- repo: https://github.com/python/black
|
||||
rev: 21.7b0
|
||||
rev: 22.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
@@ -28,3 +20,14 @@ repos:
|
||||
- --max-line-length=456
|
||||
- --show-source
|
||||
- --statistics
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
args: ["--profile", "black"]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.31.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
# TODO: remove `--keep-runtime-typing` option
|
||||
args: ["--py37-plus", "--keep-runtime-typing"]
|
||||
|
@@ -22,7 +22,7 @@ This section contains technical instructions & hints for the contributors.
|
||||
|
||||
## Type checking
|
||||
The project uses `pyright` to check types.
|
||||
To type check locally, install pyright per official [instructions](https://github.com/microsoft/pyright#command-line).
|
||||
To type check locally, install `pyright` per official [instructions](https://github.com/microsoft/pyright#command-line).
|
||||
It's configuration lives under a section of `pyproject.toml`. It includes list of files currently supporting type checks. Use `pyright` CLI command to launch type checks.
|
||||
|
||||
### Adding typing to more modules and packages
|
||||
@@ -32,3 +32,9 @@ add the path to the file(s) in the include section
|
||||
(pyproject.toml -> [tool.pyright] -> include).
|
||||
Then you can run `pyright` to see list of type problems in the newly added file, and fix them.
|
||||
|
||||
## Git hooks
|
||||
The CI will run several checks on the new code pushed to the Gym repository. These checks can also be run locally without waiting for the CI by following the steps below:
|
||||
1. [install `pre-commit`](https://pre-commit.com/#install),
|
||||
2. install the Git hooks by running `pre-commit install`.
|
||||
|
||||
Once those two steps are done, the Git hooks will be run automatically at every new commit. The Git hooks can also be run manually with `pre-commit run --all-files`, and if needed they can be skipped (not recommended) with `git commit --no-verify`. **Note:** you may have to run `pre-commit run --all-files` manually a couple of times to make it pass when you commit, as each formatting tool will first format the code and fail the first time but should pass the second time.
|
||||
|
@@ -1,3 +1,5 @@
|
||||
[](https://pre-commit.com/) [](https://github.com/psf/black)
|
||||
|
||||
## Gym
|
||||
|
||||
Gym is an open source Python library for developing and comparing reinforcement learning algorithms by providing a standard API to communicate between learning algorithms and environments, as well as a standard set of environments compliant with that API. Since its release, Gym's API has become the field standard for doing this.
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# isort: skip_file
|
||||
|
||||
from gym import error
|
||||
from gym.version import VERSION as __version__
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from typing import TypeVar, Generic, Tuple, Union, Optional, SupportsFloat
|
||||
from typing import Generic, Optional, SupportsFloat, Tuple, TypeVar, Union
|
||||
|
||||
import gym
|
||||
from gym import spaces
|
||||
from gym.utils import seeding
|
||||
from gym.logger import deprecation
|
||||
from gym.utils import seeding
|
||||
from gym.utils.seeding import RandomNumberGenerator
|
||||
|
||||
ObsType = TypeVar("ObsType")
|
||||
|
@@ -1,10 +1,5 @@
|
||||
from gym.envs.registration import (
|
||||
registry,
|
||||
register,
|
||||
make,
|
||||
spec,
|
||||
load_env_plugins as _load_env_plugins,
|
||||
)
|
||||
from gym.envs.registration import load_env_plugins as _load_env_plugins
|
||||
from gym.envs.registration import make, register, registry, spec
|
||||
|
||||
# Hook to load plugins from entry points
|
||||
_load_env_plugins()
|
||||
|
@@ -1,7 +1,8 @@
|
||||
try:
|
||||
import Box2D
|
||||
from gym.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous
|
||||
|
||||
from gym.envs.box2d.bipedal_walker import BipedalWalker, BipedalWalkerHardcore
|
||||
from gym.envs.box2d.car_racing import CarRacing
|
||||
from gym.envs.box2d.lunar_lander import LunarLander, LunarLanderContinuous
|
||||
except ImportError:
|
||||
Box2D = None
|
||||
|
@@ -1,27 +1,25 @@
|
||||
__credits__ = ["Andrea PIERRÉ"]
|
||||
|
||||
import sys
|
||||
import math
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import Box2D
|
||||
import numpy as np
|
||||
import pygame
|
||||
from pygame import gfxdraw
|
||||
|
||||
import Box2D
|
||||
from Box2D.b2 import (
|
||||
edgeShape,
|
||||
circleShape,
|
||||
contactListener,
|
||||
edgeShape,
|
||||
fixtureDef,
|
||||
polygonShape,
|
||||
revoluteJointDef,
|
||||
contactListener,
|
||||
)
|
||||
from pygame import gfxdraw
|
||||
|
||||
import gym
|
||||
from gym import error, spaces
|
||||
from gym.utils import colorize, seeding, EzPickle
|
||||
|
||||
from gym.utils import EzPickle, colorize, seeding
|
||||
|
||||
FPS = 50
|
||||
SCALE = 30.0 # affects how fast-paced the game is, forces should be adjusted as well
|
||||
@@ -582,7 +580,7 @@ class BipedalWalker(gym.Env, EzPickle):
|
||||
continue
|
||||
scaled_poly = []
|
||||
for coord in poly:
|
||||
scaled_poly.append(([coord[0] * SCALE, coord[1] * SCALE]))
|
||||
scaled_poly.append([coord[0] * SCALE, coord[1] * SCALE])
|
||||
pygame.draw.polygon(self.surf, color=color, points=scaled_poly)
|
||||
gfxdraw.aapolygon(self.surf, scaled_poly, color)
|
||||
|
||||
|
@@ -7,17 +7,18 @@ This simulation is a bit more detailed, with wheels rotation.
|
||||
Created by Oleg Klimov
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import math
|
||||
import pygame.draw
|
||||
|
||||
import Box2D
|
||||
import numpy as np
|
||||
import pygame.draw
|
||||
from Box2D.b2 import (
|
||||
edgeShape,
|
||||
circleShape,
|
||||
contactListener,
|
||||
edgeShape,
|
||||
fixtureDef,
|
||||
polygonShape,
|
||||
revoluteJointDef,
|
||||
contactListener,
|
||||
shape,
|
||||
)
|
||||
|
||||
|
@@ -1,22 +1,19 @@
|
||||
__credits__ = ["Andrea PIERRÉ"]
|
||||
|
||||
import sys
|
||||
import math
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import Box2D
|
||||
import numpy as np
|
||||
import pygame
|
||||
from Box2D.b2 import contactListener, fixtureDef, polygonShape
|
||||
from pygame import gfxdraw
|
||||
|
||||
import Box2D
|
||||
from Box2D.b2 import fixtureDef
|
||||
from Box2D.b2 import polygonShape
|
||||
from Box2D.b2 import contactListener
|
||||
|
||||
import gym
|
||||
from gym import spaces
|
||||
from gym.envs.box2d.car_dynamics import Car
|
||||
from gym.utils import seeding, EzPickle
|
||||
from gym.utils import EzPickle, seeding
|
||||
|
||||
STATE_W = 96 # less than Atari 160x192
|
||||
STATE_H = 96
|
||||
|
@@ -4,23 +4,22 @@ import math
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import Box2D
|
||||
import numpy as np
|
||||
import pygame
|
||||
from pygame import gfxdraw
|
||||
|
||||
import Box2D
|
||||
from Box2D.b2 import (
|
||||
edgeShape,
|
||||
circleShape,
|
||||
contactListener,
|
||||
edgeShape,
|
||||
fixtureDef,
|
||||
polygonShape,
|
||||
revoluteJointDef,
|
||||
contactListener,
|
||||
)
|
||||
from pygame import gfxdraw
|
||||
|
||||
import gym
|
||||
from gym import error, spaces
|
||||
from gym.utils import seeding, EzPickle
|
||||
from gym.utils import EzPickle, seeding
|
||||
|
||||
FPS = 50
|
||||
SCALE = 30.0 # affects how fast-paced the game is, forces should be adjusted as well
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from gym.envs.classic_control.cartpole import CartPoleEnv
|
||||
from gym.envs.classic_control.mountain_car import MountainCarEnv
|
||||
from gym.envs.classic_control.continuous_mountain_car import Continuous_MountainCarEnv
|
||||
from gym.envs.classic_control.pendulum import PendulumEnv
|
||||
from gym.envs.classic_control.acrobot import AcrobotEnv
|
||||
from gym.envs.classic_control.cartpole import CartPoleEnv
|
||||
from gym.envs.classic_control.continuous_mountain_car import Continuous_MountainCarEnv
|
||||
from gym.envs.classic_control.mountain_car import MountainCarEnv
|
||||
from gym.envs.classic_control.pendulum import PendulumEnv
|
||||
|
@@ -3,8 +3,8 @@ from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import pygame
|
||||
from numpy import cos, pi, sin
|
||||
from pygame import gfxdraw
|
||||
from numpy import sin, cos, pi
|
||||
|
||||
from gym import core, spaces
|
||||
from gym.utils import seeding
|
||||
@@ -240,15 +240,15 @@ class AcrobotEnv(core.Env):
|
||||
dtheta1 = s[2]
|
||||
dtheta2 = s[3]
|
||||
d1 = (
|
||||
m1 * lc1 ** 2
|
||||
+ m2 * (l1 ** 2 + lc2 ** 2 + 2 * l1 * lc2 * cos(theta2))
|
||||
m1 * lc1**2
|
||||
+ m2 * (l1**2 + lc2**2 + 2 * l1 * lc2 * cos(theta2))
|
||||
+ I1
|
||||
+ I2
|
||||
)
|
||||
d2 = m2 * (lc2 ** 2 + l1 * lc2 * cos(theta2)) + I2
|
||||
d2 = m2 * (lc2**2 + l1 * lc2 * cos(theta2)) + I2
|
||||
phi2 = m2 * lc2 * g * cos(theta1 + theta2 - pi / 2.0)
|
||||
phi1 = (
|
||||
-m2 * l1 * lc2 * dtheta2 ** 2 * sin(theta2)
|
||||
-m2 * l1 * lc2 * dtheta2**2 * sin(theta2)
|
||||
- 2 * m2 * l1 * lc2 * dtheta2 * dtheta1 * sin(theta2)
|
||||
+ (m1 * lc1 + m2 * l1) * g * cos(theta1 - pi / 2)
|
||||
+ phi2
|
||||
@@ -256,13 +256,13 @@ class AcrobotEnv(core.Env):
|
||||
if self.book_or_nips == "nips":
|
||||
# the following line is consistent with the description in the
|
||||
# paper
|
||||
ddtheta2 = (a + d2 / d1 * phi1 - phi2) / (m2 * lc2 ** 2 + I2 - d2 ** 2 / d1)
|
||||
ddtheta2 = (a + d2 / d1 * phi1 - phi2) / (m2 * lc2**2 + I2 - d2**2 / d1)
|
||||
else:
|
||||
# the following line is consistent with the java implementation and the
|
||||
# book
|
||||
ddtheta2 = (
|
||||
a + d2 / d1 * phi1 - m2 * l1 * lc2 * dtheta1 ** 2 * sin(theta2) - phi2
|
||||
) / (m2 * lc2 ** 2 + I2 - d2 ** 2 / d1)
|
||||
a + d2 / d1 * phi1 - m2 * l1 * lc2 * dtheta1**2 * sin(theta2) - phi2
|
||||
) / (m2 * lc2**2 + I2 - d2**2 / d1)
|
||||
ddtheta1 = -(d2 * ddtheta2 + phi1) / d1
|
||||
return (dtheta1, dtheta2, ddtheta1, ddtheta2, 0.0)
|
||||
|
||||
|
@@ -11,7 +11,7 @@ import pygame
|
||||
from pygame import gfxdraw
|
||||
|
||||
import gym
|
||||
from gym import spaces, logger
|
||||
from gym import logger, spaces
|
||||
from gym.utils import seeding
|
||||
|
||||
|
||||
@@ -125,10 +125,10 @@ class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):
|
||||
# For the interested reader:
|
||||
# https://coneural.org/florian/papers/05_cart_pole.pdf
|
||||
temp = (
|
||||
force + self.polemass_length * theta_dot ** 2 * sintheta
|
||||
force + self.polemass_length * theta_dot**2 * sintheta
|
||||
) / self.total_mass
|
||||
thetaacc = (self.gravity * sintheta - costheta * temp) / (
|
||||
self.length * (4.0 / 3.0 - self.masspole * costheta ** 2 / self.total_mass)
|
||||
self.length * (4.0 / 3.0 - self.masspole * costheta**2 / self.total_mass)
|
||||
)
|
||||
xacc = temp - self.polemass_length * thetaacc * costheta / self.total_mass
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
__credits__ = ["Carlos Luis"]
|
||||
|
||||
from typing import Optional
|
||||
from os import path
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import pygame
|
||||
@@ -113,9 +113,9 @@ class PendulumEnv(gym.Env):
|
||||
|
||||
u = np.clip(u, -self.max_torque, self.max_torque)[0]
|
||||
self.last_u = u # for rendering
|
||||
costs = angle_normalize(th) ** 2 + 0.1 * thdot ** 2 + 0.001 * (u ** 2)
|
||||
costs = angle_normalize(th) ** 2 + 0.1 * thdot**2 + 0.001 * (u**2)
|
||||
|
||||
newthdot = thdot + (3 * g / (2 * l) * np.sin(th) + 3.0 / (m * l ** 2) * u) * dt
|
||||
newthdot = thdot + (3 * g / (2 * l) * np.sin(th) + 3.0 / (m * l**2) * u) * dt
|
||||
newthdot = np.clip(newthdot, -self.max_speed, self.max_speed)
|
||||
newth = th + newthdot * dt
|
||||
|
||||
|
@@ -1,15 +1,14 @@
|
||||
from gym.envs.mujoco.mujoco_env import MujocoEnv
|
||||
|
||||
# ^^^^^ so that user gets the correct error
|
||||
# message if mujoco is not installed correctly
|
||||
from gym.envs.mujoco.ant import AntEnv
|
||||
from gym.envs.mujoco.half_cheetah import HalfCheetahEnv
|
||||
from gym.envs.mujoco.hopper import HopperEnv
|
||||
from gym.envs.mujoco.walker2d import Walker2dEnv
|
||||
from gym.envs.mujoco.humanoid import HumanoidEnv
|
||||
from gym.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
|
||||
from gym.envs.mujoco.humanoidstandup import HumanoidStandupEnv
|
||||
from gym.envs.mujoco.inverted_double_pendulum import InvertedDoublePendulumEnv
|
||||
from gym.envs.mujoco.inverted_pendulum import InvertedPendulumEnv
|
||||
from gym.envs.mujoco.mujoco_env import MujocoEnv
|
||||
from gym.envs.mujoco.pusher import PusherEnv
|
||||
from gym.envs.mujoco.reacher import ReacherEnv
|
||||
from gym.envs.mujoco.swimmer import SwimmerEnv
|
||||
from gym.envs.mujoco.humanoidstandup import HumanoidStandupEnv
|
||||
from gym.envs.mujoco.pusher import PusherEnv
|
||||
from gym.envs.mujoco.walker2d import Walker2dEnv
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {
|
||||
"distance": 4.0,
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
__credits__ = ["Rushiv Arora"]
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {
|
||||
"distance": 4.0,
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
__credits__ = ["Rushiv Arora"]
|
||||
|
||||
import numpy as np
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
from gym import utils
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {
|
||||
"trackbodyid": 2,
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
||||
def mass_center(model, sim):
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
from gym import utils
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {
|
||||
"trackbodyid": 1,
|
||||
|
@@ -1,7 +1,8 @@
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
from gym import utils
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
||||
class HumanoidStandupEnv(mujoco_env.MujocoEnv, utils.EzPickle):
|
||||
"""
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
@@ -117,9 +118,9 @@ class InvertedDoublePendulumEnv(mujoco_env.MujocoEnv, utils.EzPickle):
|
||||
self.do_simulation(action, self.frame_skip)
|
||||
ob = self._get_obs()
|
||||
x, _, y = self.sim.data.site_xpos[0]
|
||||
dist_penalty = 0.01 * x ** 2 + (y - 2) ** 2
|
||||
dist_penalty = 0.01 * x**2 + (y - 2) ** 2
|
||||
v1, v2 = self.sim.data.qvel[1:3]
|
||||
vel_penalty = 1e-3 * v1 ** 2 + 5e-3 * v2 ** 2
|
||||
vel_penalty = 1e-3 * v1**2 + 5e-3 * v2**2
|
||||
alive_bonus = 10
|
||||
r = alive_bonus - dist_penalty - vel_penalty
|
||||
done = bool(y <= 1)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,12 +1,13 @@
|
||||
from collections import OrderedDict
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
from os import path
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
from gym import error, spaces
|
||||
from gym.utils import seeding
|
||||
import numpy as np
|
||||
from os import path
|
||||
import gym
|
||||
|
||||
try:
|
||||
import mujoco_py
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import mujoco_py
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
import mujoco_py
|
||||
|
||||
|
||||
class PusherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
|
||||
"""
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
__credits__ = ["Rushiv Arora"]
|
||||
|
||||
import numpy as np
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
from gym import utils
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
from gym import utils
|
||||
|
||||
from gym import utils
|
||||
from gym.envs.mujoco import mujoco_env
|
||||
|
||||
DEFAULT_CAMERA_CONFIG = {
|
||||
"trackbodyid": 2,
|
||||
|
@@ -1,24 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
import contextlib
|
||||
import copy
|
||||
import difflib
|
||||
import importlib
|
||||
import importlib.util
|
||||
import contextlib
|
||||
import re
|
||||
import sys
|
||||
from typing import (
|
||||
Callable,
|
||||
Type,
|
||||
Optional,
|
||||
Union,
|
||||
Tuple,
|
||||
Generator,
|
||||
Sequence,
|
||||
cast,
|
||||
SupportsFloat,
|
||||
overload,
|
||||
Any,
|
||||
Callable,
|
||||
Generator,
|
||||
Optional,
|
||||
Sequence,
|
||||
SupportsFloat,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
cast,
|
||||
overload,
|
||||
)
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
@@ -26,16 +26,15 @@ if sys.version_info < (3, 10):
|
||||
else:
|
||||
import importlib.metadata as metadata
|
||||
|
||||
from dataclasses import dataclass, field, InitVar
|
||||
from collections import defaultdict
|
||||
from collections.abc import MutableMapping
|
||||
from dataclasses import InitVar, dataclass, field
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import error, logger, Env
|
||||
from gym import Env, error, logger
|
||||
from gym.envs.__relocated__ import internal_env_relocation_map
|
||||
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
@@ -670,9 +669,9 @@ def make(id: Literal[
|
||||
# ----------------------------------------
|
||||
|
||||
@overload
|
||||
def make(id: str, **kwargs) -> "Env": ...
|
||||
def make(id: str, **kwargs) -> Env: ...
|
||||
# fmt: on
|
||||
def make(id: str, **kwargs) -> "Env":
|
||||
def make(id: str, **kwargs) -> Env:
|
||||
return registry.make(id, **kwargs)
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from gym.envs.toy_text.blackjack import BlackjackEnv
|
||||
from gym.envs.toy_text.frozen_lake import FrozenLakeEnv
|
||||
from gym.envs.toy_text.cliffwalking import CliffWalkingEnv
|
||||
from gym.envs.toy_text.frozen_lake import FrozenLakeEnv
|
||||
from gym.envs.toy_text.taxi import TaxiEnv
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from typing import Optional
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import pygame
|
||||
|
@@ -4,6 +4,7 @@ from io import StringIO
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import Env, spaces
|
||||
from gym.envs.toy_text.utils import categorical_sample
|
||||
|
||||
|
@@ -2,9 +2,10 @@ from contextlib import closing
|
||||
from io import StringIO
|
||||
from os import path
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import pygame
|
||||
from pygame.constants import SRCALPHA
|
||||
import numpy as np
|
||||
|
||||
from gym import Env, spaces, utils
|
||||
from gym.envs.toy_text.utils import categorical_sample
|
||||
|
@@ -4,6 +4,7 @@ from io import StringIO
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import Env, spaces, utils
|
||||
from gym.envs.toy_text.utils import categorical_sample
|
||||
|
||||
|
@@ -1,15 +1,11 @@
|
||||
from gym.spaces.space import Space
|
||||
from gym.spaces.box import Box
|
||||
from gym.spaces.discrete import Discrete
|
||||
from gym.spaces.multi_discrete import MultiDiscrete
|
||||
from gym.spaces.multi_binary import MultiBinary
|
||||
from gym.spaces.tuple import Tuple
|
||||
from gym.spaces.dict import Dict
|
||||
|
||||
from gym.spaces.utils import flatdim
|
||||
from gym.spaces.utils import flatten_space
|
||||
from gym.spaces.utils import flatten
|
||||
from gym.spaces.utils import unflatten
|
||||
from gym.spaces.discrete import Discrete
|
||||
from gym.spaces.multi_binary import MultiBinary
|
||||
from gym.spaces.multi_discrete import MultiDiscrete
|
||||
from gym.spaces.space import Space
|
||||
from gym.spaces.tuple import Tuple
|
||||
from gym.spaces.utils import flatdim, flatten, flatten_space, unflatten
|
||||
|
||||
__all__ = [
|
||||
"Space",
|
||||
|
@@ -1,12 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple, SupportsFloat, Union, Type, Optional, Sequence
|
||||
from typing import Optional, Sequence, SupportsFloat, Tuple, Type, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .space import Space
|
||||
from gym import logger
|
||||
|
||||
from .space import Space
|
||||
|
||||
|
||||
def _short_repr(arr: np.ndarray) -> str:
|
||||
"""Create a shortened string representation of a numpy array.
|
||||
|
@@ -3,7 +3,9 @@ from __future__ import annotations
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import Dict as TypingDict
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .space import Space
|
||||
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .space import Space
|
||||
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, Union, Sequence
|
||||
from typing import Optional, Sequence, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .space import Space
|
||||
|
||||
|
||||
|
@@ -1,10 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import logger
|
||||
from .space import Space
|
||||
|
||||
from .discrete import Discrete
|
||||
from .space import Space
|
||||
|
||||
|
||||
class MultiDiscrete(Space[np.ndarray]):
|
||||
|
@@ -1,20 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import (
|
||||
TypeVar,
|
||||
Generic,
|
||||
Optional,
|
||||
Sequence,
|
||||
Iterable,
|
||||
Mapping,
|
||||
Type,
|
||||
)
|
||||
from typing import Generic, Iterable, Mapping, Optional, Sequence, Type, TypeVar
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym.utils import seeding
|
||||
|
||||
|
||||
T_cov = TypeVar("T_cov", covariant=True)
|
||||
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
from collections.abc import Sequence
|
||||
from typing import Iterable, List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .space import Space
|
||||
|
||||
|
||||
|
@@ -1,18 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import OrderedDict
|
||||
from functools import singledispatch, reduce
|
||||
from typing import TypeVar, Union
|
||||
import numpy as np
|
||||
import operator as op
|
||||
from collections import OrderedDict
|
||||
from functools import reduce, singledispatch
|
||||
from typing import TypeVar, Union
|
||||
|
||||
from gym.spaces import Box
|
||||
from gym.spaces import Discrete
|
||||
from gym.spaces import MultiDiscrete
|
||||
from gym.spaces import MultiBinary
|
||||
from gym.spaces import Tuple
|
||||
from gym.spaces import Dict
|
||||
from gym.spaces import Space
|
||||
import numpy as np
|
||||
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
|
||||
|
||||
|
||||
@singledispatch
|
||||
|
@@ -10,13 +10,13 @@ Original Author: J K Terry
|
||||
These projects are covered by the MIT License.
|
||||
"""
|
||||
|
||||
from typing import Union, Optional
|
||||
import inspect
|
||||
from typing import Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
import numpy as np
|
||||
from gym import logger
|
||||
from gym import spaces
|
||||
from gym import logger, spaces
|
||||
|
||||
|
||||
def _is_numpy_array_space(space: spaces.Space) -> bool:
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import gym
|
||||
import pygame
|
||||
import matplotlib
|
||||
import argparse
|
||||
|
||||
import matplotlib
|
||||
import pygame
|
||||
|
||||
import gym
|
||||
from gym import logger
|
||||
|
||||
try:
|
||||
@@ -12,6 +14,7 @@ except ImportError as e:
|
||||
plt = None
|
||||
|
||||
from collections import deque
|
||||
|
||||
from pygame.locals import VIDEORESIZE
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import hashlib
|
||||
from typing import Optional, List, Tuple, Union, Any
|
||||
import os
|
||||
import struct
|
||||
from typing import Any, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
from numpy.random import Generator
|
||||
@@ -198,6 +198,6 @@ def _int_list_from_bigint(bigint: int) -> List[int]:
|
||||
|
||||
ints: List[int] = []
|
||||
while bigint > 0:
|
||||
bigint, mod = divmod(bigint, 2 ** 32)
|
||||
bigint, mod = divmod(bigint, 2**32)
|
||||
ints.append(mod)
|
||||
return ints
|
||||
|
@@ -1,31 +1,31 @@
|
||||
from typing import Optional, Union, List
|
||||
import multiprocessing as mp
|
||||
import sys
|
||||
import time
|
||||
from copy import deepcopy
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
import multiprocessing as mp
|
||||
import time
|
||||
import sys
|
||||
from enum import Enum
|
||||
from copy import deepcopy
|
||||
|
||||
from gym import logger
|
||||
from gym.logger import warn
|
||||
from gym.vector.vector_env import VectorEnv
|
||||
from gym.error import (
|
||||
AlreadyPendingCallError,
|
||||
NoAsyncCallError,
|
||||
ClosedEnvironmentError,
|
||||
CustomSpaceError,
|
||||
NoAsyncCallError,
|
||||
)
|
||||
from gym.logger import warn
|
||||
from gym.vector.utils import (
|
||||
create_shared_memory,
|
||||
create_empty_array,
|
||||
write_to_shared_memory,
|
||||
read_from_shared_memory,
|
||||
concatenate,
|
||||
iterate,
|
||||
CloudpickleWrapper,
|
||||
clear_mpi_env_vars,
|
||||
concatenate,
|
||||
create_empty_array,
|
||||
create_shared_memory,
|
||||
iterate,
|
||||
read_from_shared_memory,
|
||||
write_to_shared_memory,
|
||||
)
|
||||
from gym.vector.vector_env import VectorEnv
|
||||
|
||||
__all__ = ["AsyncVectorEnv"]
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
from typing import List, Union, Optional
|
||||
from copy import deepcopy
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
from copy import deepcopy
|
||||
|
||||
from gym import logger
|
||||
from gym.logger import warn
|
||||
from gym.vector.utils import concatenate, create_empty_array, iterate
|
||||
from gym.vector.vector_env import VectorEnv
|
||||
from gym.vector.utils import concatenate, iterate, create_empty_array
|
||||
|
||||
__all__ = ["SyncVectorEnv"]
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from collections import OrderedDict
|
||||
from functools import singledispatch
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym.spaces import Space, Box, Discrete, MultiDiscrete, MultiBinary, Tuple, Dict
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
|
||||
from gym.vector.utils.spaces import _BaseGymSpaces
|
||||
from collections import OrderedDict
|
||||
|
||||
from functools import singledispatch
|
||||
|
||||
__all__ = ["concatenate", "create_empty_array"]
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
import numpy as np
|
||||
import multiprocessing as mp
|
||||
from ctypes import c_bool
|
||||
from collections import OrderedDict
|
||||
from ctypes import c_bool
|
||||
from functools import singledispatch
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import logger
|
||||
from gym.spaces import Space, Box, Discrete, MultiDiscrete, MultiBinary, Tuple, Dict
|
||||
from gym.error import CustomSpaceError
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
|
||||
from gym.vector.utils.spaces import _BaseGymSpaces
|
||||
|
||||
from functools import singledispatch
|
||||
|
||||
__all__ = ["create_shared_memory", "read_from_shared_memory", "write_to_shared_memory"]
|
||||
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import numpy as np
|
||||
from collections import OrderedDict
|
||||
from functools import singledispatch
|
||||
|
||||
from gym.spaces import Space, Box, Discrete, MultiDiscrete, MultiBinary, Tuple, Dict
|
||||
import numpy as np
|
||||
|
||||
from gym.error import CustomSpaceError
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
|
||||
|
||||
_BaseGymSpaces = (Box, Discrete, MultiDiscrete, MultiBinary)
|
||||
__all__ = ["_BaseGymSpaces", "batch_space", "iterate"]
|
||||
@@ -131,8 +132,7 @@ def iterate(space, items):
|
||||
StopIteration
|
||||
"""
|
||||
raise ValueError(
|
||||
"Space of type `{0}` is not a valid `gym.Space` "
|
||||
"instance.".format(type(space))
|
||||
"Space of type `{}` is not a valid `gym.Space` " "instance.".format(type(space))
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
from typing import Optional, Union, List
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import gym
|
||||
from gym.logger import warn, deprecation
|
||||
from gym.logger import deprecation, warn
|
||||
from gym.spaces import Tuple
|
||||
from gym.vector.utils.spaces import batch_space
|
||||
|
||||
|
@@ -1,19 +1,18 @@
|
||||
from gym import error
|
||||
from gym.wrappers.time_limit import TimeLimit
|
||||
from gym.wrappers.filter_observation import FilterObservation
|
||||
from gym.wrappers.atari_preprocessing import AtariPreprocessing
|
||||
from gym.wrappers.time_aware_observation import TimeAwareObservation
|
||||
from gym.wrappers.rescale_action import RescaleAction
|
||||
from gym.wrappers.autoreset import AutoResetWrapper
|
||||
from gym.wrappers.clip_action import ClipAction
|
||||
from gym.wrappers.filter_observation import FilterObservation
|
||||
from gym.wrappers.flatten_observation import FlattenObservation
|
||||
from gym.wrappers.frame_stack import FrameStack, LazyFrames
|
||||
from gym.wrappers.gray_scale_observation import GrayScaleObservation
|
||||
from gym.wrappers.frame_stack import LazyFrames
|
||||
from gym.wrappers.frame_stack import FrameStack
|
||||
from gym.wrappers.normalize import NormalizeObservation, NormalizeReward
|
||||
from gym.wrappers.order_enforcing import OrderEnforcing
|
||||
from gym.wrappers.record_episode_statistics import RecordEpisodeStatistics
|
||||
from gym.wrappers.record_video import RecordVideo, capped_cubic_video_schedule
|
||||
from gym.wrappers.rescale_action import RescaleAction
|
||||
from gym.wrappers.resize_observation import ResizeObservation
|
||||
from gym.wrappers.time_aware_observation import TimeAwareObservation
|
||||
from gym.wrappers.time_limit import TimeLimit
|
||||
from gym.wrappers.transform_observation import TransformObservation
|
||||
from gym.wrappers.transform_reward import TransformReward
|
||||
from gym.wrappers.resize_observation import ResizeObservation
|
||||
from gym.wrappers.clip_action import ClipAction
|
||||
from gym.wrappers.record_episode_statistics import RecordEpisodeStatistics
|
||||
from gym.wrappers.normalize import NormalizeObservation, NormalizeReward
|
||||
from gym.wrappers.record_video import RecordVideo, capped_cubic_video_schedule
|
||||
from gym.wrappers.order_enforcing import OrderEnforcing
|
||||
from gym.wrappers.autoreset import AutoResetWrapper
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
from gym.spaces import Box
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from gym import ActionWrapper
|
||||
from gym.spaces import Box
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import copy
|
||||
from gym import spaces
|
||||
from gym import ObservationWrapper
|
||||
|
||||
from gym import ObservationWrapper, spaces
|
||||
|
||||
|
||||
class FilterObservation(ObservationWrapper):
|
||||
|
@@ -2,8 +2,9 @@ from collections import deque
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
from gym.spaces import Box
|
||||
|
||||
from gym import ObservationWrapper
|
||||
from gym.spaces import Box
|
||||
|
||||
|
||||
class LazyFrames:
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
from gym.spaces import Box
|
||||
|
||||
from gym import ObservationWrapper
|
||||
from gym.spaces import Box
|
||||
|
||||
|
||||
class GrayScaleObservation(ObservationWrapper):
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import distutils.spawn
|
||||
import distutils.version
|
||||
import json
|
||||
import os
|
||||
import os.path
|
||||
@@ -6,8 +8,6 @@ import subprocess
|
||||
import tempfile
|
||||
from io import StringIO
|
||||
|
||||
import distutils.spawn
|
||||
import distutils.version
|
||||
import numpy as np
|
||||
|
||||
from gym import error, logger
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
|
||||
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import collections
|
||||
from collections.abc import MutableMapping
|
||||
import copy
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import spaces
|
||||
from gym import ObservationWrapper
|
||||
|
||||
from gym import ObservationWrapper, spaces
|
||||
|
||||
STATE_KEY = "state"
|
||||
|
||||
|
@@ -3,6 +3,7 @@ from collections import deque
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import gym
|
||||
from typing import Callable, Optional
|
||||
|
||||
import gym
|
||||
from gym import logger
|
||||
from gym.wrappers.monitoring import video_recorder
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
import gym
|
||||
from gym import spaces
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
from gym.spaces import Box
|
||||
|
||||
from gym import ObservationWrapper
|
||||
from gym.spaces import Box
|
||||
|
||||
|
||||
class ResizeObservation(ObservationWrapper):
|
||||
|
@@ -1,8 +1,9 @@
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
from gym.spaces import Box
|
||||
|
||||
from gym import ObservationWrapper
|
||||
from gym.spaces import Box
|
||||
|
||||
|
||||
class TimeAwareObservation(ObservationWrapper):
|
||||
|
6
setup.py
6
setup.py
@@ -1,6 +1,6 @@
|
||||
import itertools
|
||||
import os.path
|
||||
import sys
|
||||
import itertools
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
@@ -20,7 +20,7 @@ extras = {
|
||||
}
|
||||
|
||||
# Meta dependency groups.
|
||||
nomujoco_blacklist = set(["mujoco", "accept-rom-license", "atari"])
|
||||
nomujoco_blacklist = {"mujoco", "accept-rom-license", "atari"}
|
||||
nomujoco_groups = set(extras.keys()) - nomujoco_blacklist
|
||||
|
||||
extras["nomujoco"] = list(
|
||||
@@ -28,7 +28,7 @@ extras["nomujoco"] = list(
|
||||
)
|
||||
|
||||
|
||||
all_blacklist = set(["accept-rom-license"])
|
||||
all_blacklist = {"accept-rom-license"}
|
||||
all_groups = set(extras.keys()) - all_blacklist
|
||||
|
||||
extras["all"] = list(
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from gym import envs, logger
|
||||
import os
|
||||
|
||||
from gym import envs, logger
|
||||
|
||||
SKIP_MUJOCO_WARNING_MESSAGE = (
|
||||
"Cannot run mujoco test (either license key not found or mujoco not"
|
||||
|
@@ -3,8 +3,7 @@ import pickle
|
||||
import pytest
|
||||
|
||||
from gym import envs
|
||||
from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
|
||||
|
||||
from tests.envs.spec_list import SKIP_MUJOCO_WARNING_MESSAGE, skip_mujoco
|
||||
|
||||
ENVIRONMENT_IDS = ("HalfCheetah-v2",)
|
||||
|
||||
|
@@ -2,10 +2,10 @@ import pytest
|
||||
|
||||
pytest.importorskip("gym.envs.atari")
|
||||
|
||||
from gym.envs.registration import registry
|
||||
|
||||
from itertools import product
|
||||
|
||||
from gym.envs.registration import registry
|
||||
|
||||
|
||||
def test_ale_legacy_env_specs():
|
||||
versions = ["-v0", "-v4"]
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym import envs
|
||||
from tests.envs.spec_list import spec_list
|
||||
from gym.spaces import Box
|
||||
from gym.utils.env_checker import check_env
|
||||
from tests.envs.spec_list import spec_list
|
||||
|
||||
|
||||
# This runs a smoketest on each official registered env. We may want
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.envs.toy_text.frozen_lake import generate_random_map
|
||||
|
||||
|
@@ -2,10 +2,8 @@ import pytest
|
||||
|
||||
try:
|
||||
import Box2D
|
||||
from gym.envs.box2d.lunar_lander import (
|
||||
LunarLander,
|
||||
demo_heuristic_lander,
|
||||
)
|
||||
|
||||
from gym.envs.box2d.lunar_lander import LunarLander, demo_heuristic_lander
|
||||
except ImportError:
|
||||
Box2D = None
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gym import envs
|
||||
from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
|
||||
from tests.envs.spec_list import SKIP_MUJOCO_WARNING_MESSAGE, skip_mujoco
|
||||
|
||||
|
||||
def verify_environments_match(
|
||||
|
@@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym import error, envs
|
||||
from gym import envs, error
|
||||
from gym.envs import registration
|
||||
from gym.envs.classic_control import cartpole
|
||||
from gym.envs.registration import EnvSpec, EnvSpecTree
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import json # note: ujson fails this test due to float equality
|
||||
import copy
|
||||
import json # note: ujson fails this test due to float equality
|
||||
import pickle
|
||||
import tempfile
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Tuple, Box, Discrete, MultiDiscrete, MultiBinary, Dict
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@@ -5,7 +5,6 @@ import pytest
|
||||
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple, utils
|
||||
|
||||
|
||||
spaces = [
|
||||
Discrete(3),
|
||||
Box(low=0.0, high=np.inf, shape=(2, 2)),
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym import core, spaces
|
||||
from gym.wrappers import TimeLimit, OrderEnforcing
|
||||
from gym.wrappers import OrderEnforcing, TimeLimit
|
||||
|
||||
|
||||
class ArgumentEnv(core.Env):
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
import gym
|
||||
import numpy as np
|
||||
import pytest
|
||||
from gym.spaces import Box, Dict, Discrete
|
||||
|
||||
import gym
|
||||
from gym.spaces import Box, Dict, Discrete
|
||||
from gym.utils.env_checker import check_env
|
||||
|
||||
|
||||
|
@@ -1,18 +1,18 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from multiprocessing import TimeoutError
|
||||
from gym.spaces import Box, Tuple, Discrete, MultiDiscrete
|
||||
from gym.error import AlreadyPendingCallError, NoAsyncCallError, ClosedEnvironmentError
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.error import AlreadyPendingCallError, ClosedEnvironmentError, NoAsyncCallError
|
||||
from gym.spaces import Box, Discrete, MultiDiscrete, Tuple
|
||||
from gym.vector.async_vector_env import AsyncVectorEnv
|
||||
from tests.vector.utils import (
|
||||
CustomSpace,
|
||||
make_custom_space_env,
|
||||
make_env,
|
||||
make_slow_env,
|
||||
make_custom_space_env,
|
||||
)
|
||||
|
||||
from gym.vector.async_vector_env import AsyncVectorEnv
|
||||
|
||||
|
||||
@pytest.mark.parametrize("shared_memory", [True, False])
|
||||
def test_create_async_vector_env(shared_memory):
|
||||
|
@@ -1,14 +1,13 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from gym.spaces import Tuple, Dict
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Dict, Tuple
|
||||
from gym.vector.utils.numpy_utils import concatenate, create_empty_array
|
||||
from gym.vector.utils.spaces import _BaseGymSpaces
|
||||
from tests.vector.utils import spaces
|
||||
|
||||
from gym.vector.utils.numpy_utils import concatenate, create_empty_array
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"space", spaces, ids=[space.__class__.__name__ for space in spaces]
|
||||
|
@@ -1,22 +1,20 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
import multiprocessing as mp
|
||||
from multiprocessing.sharedctypes import SynchronizedArray
|
||||
from multiprocessing import Array, Process
|
||||
from collections import OrderedDict
|
||||
from multiprocessing import Array, Process
|
||||
from multiprocessing.sharedctypes import SynchronizedArray
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Tuple, Dict
|
||||
from gym.error import CustomSpaceError
|
||||
from gym.vector.utils.spaces import _BaseGymSpaces
|
||||
from tests.vector.utils import spaces, custom_spaces
|
||||
|
||||
from gym.spaces import Dict, Tuple
|
||||
from gym.vector.utils.shared_memory import (
|
||||
create_shared_memory,
|
||||
read_from_shared_memory,
|
||||
write_to_shared_memory,
|
||||
)
|
||||
|
||||
from gym.vector.utils.spaces import _BaseGymSpaces
|
||||
from tests.vector.utils import custom_spaces, spaces
|
||||
|
||||
expected_types = [
|
||||
Array("d", 1),
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Box, MultiDiscrete, Tuple, Dict
|
||||
from tests.vector.utils import spaces, custom_spaces, CustomSpace
|
||||
|
||||
from gym.spaces import Box, Dict, MultiDiscrete, Tuple
|
||||
from gym.vector.utils.spaces import batch_space, iterate
|
||||
from tests.vector.utils import CustomSpace, custom_spaces, spaces
|
||||
|
||||
expected_batch_spaces_4 = [
|
||||
Box(low=-1.0, high=1.0, shape=(4,), dtype=np.float64),
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Box, Tuple, Discrete, MultiDiscrete
|
||||
from tests.vector.utils import CustomSpace, make_env, make_custom_space_env
|
||||
|
||||
from gym.spaces import Box, Discrete, MultiDiscrete, Tuple
|
||||
from gym.vector.sync_vector_env import SyncVectorEnv
|
||||
from tests.vector.utils import CustomSpace, make_custom_space_env, make_env
|
||||
|
||||
|
||||
def test_create_sync_vector_env():
|
||||
|
@@ -1,12 +1,11 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from gym.spaces import Tuple
|
||||
from tests.vector.utils import CustomSpace, make_env
|
||||
|
||||
from gym.vector.async_vector_env import AsyncVectorEnv
|
||||
from gym.vector.sync_vector_env import SyncVectorEnv
|
||||
from gym.vector.vector_env import VectorEnv
|
||||
from tests.vector.utils import CustomSpace, make_env
|
||||
|
||||
|
||||
@pytest.mark.parametrize("shared_memory", [True, False])
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import gym
|
||||
from gym.vector import make
|
||||
from gym.vector import VectorEnvWrapper
|
||||
from gym.vector import VectorEnvWrapper, make
|
||||
|
||||
|
||||
class DummyWrapper(VectorEnvWrapper):
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import gym
|
||||
import time
|
||||
|
||||
from gym.spaces import Box, Discrete, MultiDiscrete, MultiBinary, Tuple, Dict
|
||||
import gym
|
||||
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple
|
||||
|
||||
spaces = [
|
||||
Box(low=np.array(-1.0), high=np.array(1.0), dtype=np.float64),
|
||||
|
@@ -7,7 +7,7 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym.spaces import Box, Dict, unflatten, flatten
|
||||
from gym.spaces import Box, Dict, flatten, unflatten
|
||||
from gym.wrappers import FlattenObservation
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
"""Tests for the filter observation wrapper."""
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym.spaces import Dict, Box, Discrete, Tuple
|
||||
from gym.spaces import Box, Dict, Discrete, Tuple
|
||||
from gym.wrappers import FilterObservation, FlattenObservation
|
||||
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym.wrappers import AtariPreprocessing
|
||||
import pytest
|
||||
|
||||
pytest.importorskip("gym.envs.atari")
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym.wrappers import AutoResetWrapper
|
||||
|
@@ -1,7 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import gym
|
||||
from gym import spaces
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user