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
This commit is contained in:
Mark Towers
2022-04-26 16:18:37 +01:00
committed by GitHub
parent 4ecc2ad35a
commit bf093c6890
56 changed files with 94 additions and 148 deletions

View File

@@ -10,12 +10,13 @@ repos:
- id: codespell
args:
- --ignore-words-list=nd,reacher,thist,ths
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://gitlab.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args:
- --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841,W503,E302,E704
- '--per-file-ignores=*/__init__.py:F401 gym/envs/registration.py:E704'
- --ignore=E203,W503,E741
- --max-complexity=30
- --max-line-length=456
- --show-source
@@ -26,7 +27,7 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v2.32.0
hooks:
- id: pyupgrade
# TODO: remove `--keep-runtime-typing` option

View File

@@ -3,7 +3,6 @@ from __future__ import annotations
from abc import abstractmethod
from typing import Generic, Optional, SupportsFloat, Tuple, TypeVar, Union
import gym
from gym import spaces
from gym.logger import deprecation
from gym.utils import seeding

View File

@@ -1,7 +1,6 @@
__credits__ = ["Andrea PIERRÉ"]
import math
import sys
from typing import Optional
import Box2D
@@ -17,7 +16,7 @@ from Box2D.b2 import (
import gym
from gym import error, spaces
from gym.utils import EzPickle, colorize, seeding
from gym.utils import EzPickle
FPS = 50
SCALE = 30.0 # affects how fast-paced the game is, forces should be adjusted as well
@@ -422,9 +421,6 @@ class BipedalWalker(gym.Env, EzPickle):
self.scroll = 0.0
self.lidar_render = 0
W = VIEWPORT_W / SCALE
H = VIEWPORT_H / SCALE
self._generate_terrain(self.hardcore)
self._generate_clouds()

View File

@@ -9,17 +9,8 @@ Created by Oleg Klimov
import math
import Box2D
import numpy as np
from Box2D.b2 import (
circleShape,
contactListener,
edgeShape,
fixtureDef,
polygonShape,
revoluteJointDef,
shape,
)
from Box2D.b2 import fixtureDef, polygonShape, revoluteJointDef
SIZE = 0.02
ENGINE_POWER = 100000000 * SIZE * SIZE

View File

@@ -1,7 +1,6 @@
__credits__ = ["Andrea PIERRÉ"]
import math
import sys
from typing import Optional
import Box2D
@@ -11,7 +10,7 @@ from Box2D.b2 import contactListener, fixtureDef, polygonShape
import gym
from gym import spaces
from gym.envs.box2d.car_dynamics import Car
from gym.utils import EzPickle, seeding
from gym.utils import EzPickle
STATE_W = 96 # less than Atari 160x192
STATE_H = 96
@@ -700,6 +699,6 @@ if __name__ == "__main__":
print(f"step {steps} total_reward {total_reward:+0.2f}")
steps += 1
isopen = env.render()
if done or restart or isopen == False:
if done or restart or isopen is False:
break
env.close()

View File

@@ -1,7 +1,6 @@
__credits__ = ["Andrea PIERRÉ"]
import math
import sys
from typing import Optional
import Box2D
@@ -17,7 +16,7 @@ from Box2D.b2 import (
import gym
from gym import error, spaces
from gym.utils import EzPickle, seeding
from gym.utils import EzPickle
FPS = 50
SCALE = 30.0 # affects how fast-paced the game is, forces should be adjusted as well
@@ -713,7 +712,7 @@ def demo_heuristic_lander(env, seed=None, render=False):
if render:
still_open = env.render()
if still_open == False:
if still_open is False:
break
if steps % 20 == 0 or done:

View File

@@ -5,7 +5,6 @@ import numpy as np
from numpy import cos, pi, sin
from gym import core, spaces
from gym.utils import seeding
__copyright__ = "Copyright 2013, RLPy http://acl.mit.edu/RLPy"
__credits__ = [

View File

@@ -10,7 +10,6 @@ import numpy as np
import gym
from gym import logger, spaces
from gym.utils import seeding
class CartPoleEnv(gym.Env[np.ndarray, Union[int, np.ndarray]]):

View File

@@ -20,7 +20,6 @@ import numpy as np
import gym
from gym import spaces
from gym.utils import seeding
class Continuous_MountainCarEnv(gym.Env):

View File

@@ -9,7 +9,6 @@ import numpy as np
import gym
from gym import spaces
from gym.utils import seeding
class MountainCarEnv(gym.Env):

View File

@@ -7,7 +7,6 @@ import numpy as np
import gym
from gym import spaces
from gym.utils import seeding
class PendulumEnv(gym.Env):

View File

@@ -7,7 +7,6 @@ import numpy as np
import gym
from gym import error, spaces
from gym.utils import seeding
try:
import mujoco_py

View File

@@ -1,4 +1,3 @@
import mujoco_py
import numpy as np
from gym import utils

View File

@@ -7,6 +7,7 @@ import importlib
import importlib.util
import re
import sys
import warnings
from dataclasses import dataclass, field
from typing import (
Any,
@@ -225,6 +226,7 @@ def load_env_plugins(entry_point: str = "gym.envs") -> None:
for plugin in metadata.entry_points(group=entry_point):
# Python 3.8 doesn't support plugin.module, plugin.attr
# So we'll have to try and parse this ourselves
module, attr = None, None
try:
module, attr = plugin.module, plugin.attr # type: ignore ## error: Cannot access member "attr" for type "EntryPoint"
except AttributeError:
@@ -232,7 +234,10 @@ def load_env_plugins(entry_point: str = "gym.envs") -> None:
module, attr = plugin.value.split(":", maxsplit=1)
else:
module, attr = plugin.value, None
except:
except Exception as e:
warnings.warn(
f"While trying to load plugin `{plugin}` from {entry_point}, an exception occurred: {e}"
)
module, attr = None, None
finally:
if attr is None:
@@ -264,8 +269,12 @@ def load_env_plugins(entry_point: str = "gym.envs") -> None:
# fmt: off
# Classic control
# ----------------------------------------
@overload
def make(id: Literal["CartPole-v0", "CartPole-v1"], **kwargs) -> Env[np.ndarray, np.ndarray | int]: ...
def make(id: Literal["CartPole-v1"], **kwargs) -> Env[np.ndarray, np.ndarray | int]: ...
@overload
def make(id: Literal["MountainCar-v0"], **kwargs) -> Env[np.ndarray, np.ndarray | int]: ...
@overload
@@ -278,6 +287,7 @@ def make(id: Literal["Acrobot-v1"], **kwargs) -> Env[np.ndarray, np.ndarray | in
# Box2d
# ----------------------------------------
@overload
def make(id: Literal["LunarLander-v2", "LunarLanderContinuous-v2"], **kwargs) -> Env[np.ndarray, np.ndarray | int]: ...
@overload
@@ -288,6 +298,7 @@ def make(id: Literal["CarRacing-v1", "CarRacingDomainRandomize-v1"], **kwargs) -
# Toy Text
# ----------------------------------------
@overload
def make(id: Literal["Blackjack-v1"], **kwargs) -> Env[np.ndarray, np.ndarray | int]: ...
@overload
@@ -299,6 +310,8 @@ def make(id: Literal["Taxi-v3"], **kwargs) -> Env[np.ndarray, np.ndarray | int]:
# Mujoco
# ----------------------------------------
@overload
def make(id: Literal[
"Reacher-v2",

View File

@@ -5,7 +5,6 @@ import numpy as np
import gym
from gym import spaces
from gym.utils import seeding
def cmp(a, b):

View File

@@ -242,7 +242,6 @@ class FrozenLakeEnv(Env):
def _render_gui(self, desc, mode):
import pygame
from pygame.constants import SRCALPHA
if self.window_surface is None:
pygame.init()

View File

@@ -1,6 +1,3 @@
import sys
class Error(Exception):
pass
@@ -133,7 +130,7 @@ class APIError(Error):
if http_body and hasattr(http_body, "decode"):
try:
http_body = http_body.decode("utf-8")
except:
except Exception:
http_body = "<Could not decode body as utf-8.>"
self._message = message

View File

@@ -5,5 +5,5 @@ not intended as API functions, and will not remain stable over time.
# These submodules should not have any import-time dependencies.
# We want this since we use `utils` during our import-time sanity checks
# that verify that our dependencies are actually present.
from .colorize import colorize
from .ezpickle import EzPickle
from gym.utils.colorize import colorize
from gym.utils.ezpickle import EzPickle

View File

@@ -5,7 +5,6 @@ from numpy.typing import NDArray
from pygame import Surface
from pygame.event import Event
import gym
from gym import Env, logger
try:

View File

@@ -4,7 +4,6 @@ import struct
from typing import Any, List, Optional, Tuple, Union
import numpy as np
from numpy.random import Generator
from gym import error
from gym.logger import deprecation

View File

@@ -14,7 +14,6 @@ from gym.error import (
CustomSpaceError,
NoAsyncCallError,
)
from gym.logger import warn
from gym.vector.utils import (
CloudpickleWrapper,
clear_mpi_env_vars,
@@ -639,7 +638,7 @@ def _worker(index, env_fn, pipe, parent_pipe, shared_memory, error_queue):
while True:
command, data = pipe.recv()
if command == "reset":
if "return_info" in data and data["return_info"] == True:
if "return_info" in data and data["return_info"] is True:
observation, info = env.reset(**data)
pipe.send(((observation, info), True))
else:
@@ -703,7 +702,7 @@ def _worker_shared_memory(index, env_fn, pipe, parent_pipe, shared_memory, error
while True:
command, data = pipe.recv()
if command == "reset":
if "return_info" in data and data["return_info"] == True:
if "return_info" in data and data["return_info"] is True:
observation, info = env.reset(**data)
write_to_shared_memory(
observation_space, index, observation, shared_memory

View File

@@ -3,8 +3,6 @@ from typing import List, Optional, Union
import numpy as np
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
@@ -108,7 +106,7 @@ class SyncVectorEnv(VectorEnv):
kwargs["seed"] = single_seed
if options is not None:
kwargs["options"] = options
if return_info == True:
if return_info is True:
kwargs["return_info"] = return_info
if not return_info:

View File

@@ -4,7 +4,6 @@ from functools import singledispatch
import numpy as np
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
from gym.vector.utils.spaces import _BaseGymSpaces
__all__ = ["concatenate", "create_empty_array"]

View File

@@ -5,10 +5,8 @@ from functools import singledispatch
import numpy as np
from gym import logger
from gym.error import CustomSpaceError
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Space, Tuple
from gym.vector.utils.spaces import _BaseGymSpaces
from gym.spaces import Box, Dict, Discrete, MultiBinary, MultiDiscrete, Tuple
__all__ = ["create_shared_memory", "read_from_shared_memory", "write_to_shared_memory"]

View File

@@ -1,8 +1,7 @@
from typing import List, Optional, Union
import gym
from gym.logger import deprecation, warn
from gym.spaces import Tuple
from gym.logger import deprecation
from gym.vector.utils.spaces import batch_space
__all__ = ["VectorEnv"]

View File

@@ -1,4 +1,3 @@
from gym import error
from gym.wrappers.atari_preprocessing import AtariPreprocessing
from gym.wrappers.autoreset import AutoResetWrapper
from gym.wrappers.clip_action import ClipAction

View File

@@ -1,5 +1,4 @@
from collections import deque
from typing import Optional
import numpy as np

View File

@@ -418,7 +418,7 @@ class ImageEncoder:
try:
self.proc.stdin.write(frame.tobytes())
except Exception as e:
except Exception:
stdout, stderr = self.proc.communicate()
logger.error("VideoRecorder encoder failed: %s", stderr)

View File

@@ -1,5 +1,3 @@
from typing import Optional
import numpy as np
import gym

View File

@@ -1,5 +1,3 @@
from typing import Optional
import gym

View File

@@ -1,6 +1,5 @@
import time
from collections import deque
from typing import Optional
import numpy as np

View File

@@ -1,5 +1,5 @@
import os
from typing import Callable, Optional
from typing import Callable
import gym
from gym import logger

View File

@@ -1,5 +1,3 @@
from typing import Optional
import numpy as np
from gym import ObservationWrapper

View File

@@ -1,5 +1,3 @@
from typing import Optional
import gym

View File

@@ -6,7 +6,7 @@ from setuptools import find_packages, setup
# Don't import gym module here, since deps may not be installed
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "gym"))
from version import VERSION
from version import VERSION # noqa:E402
# Environment-specific dependencies.
extras = {

View File

@@ -11,7 +11,7 @@ SKIP_MUJOCO_WARNING_MESSAGE = (
skip_mujoco = not (os.environ.get("MUJOCO_KEY"))
if not skip_mujoco:
try:
import mujoco_py
import mujoco_py # noqa:F401
except ImportError:
skip_mujoco = True
@@ -24,12 +24,12 @@ def should_skip_env_spec_for_tests(spec):
if skip_mujoco and ep.startswith("gym.envs.mujoco"):
return True
try:
import gym.envs.atari
import gym.envs.atari # noqa:F401
except ImportError:
if ep.startswith("gym.envs.atari"):
return True
try:
import Box2D
import Box2D # noqa:F401
except ImportError:
if ep.startswith("gym.envs.box2d"):
return True

View File

@@ -1,5 +1,3 @@
import pickle
import pytest
from gym import envs

View File

@@ -1,11 +1,11 @@
import pytest
pytest.importorskip("gym.envs.atari")
from itertools import product
import pytest
from gym.envs.registration import registry
pytest.importorskip("gym.envs.atari")
def test_ale_legacy_env_specs():
versions = ["-v0", "-v4"]

View File

@@ -61,7 +61,7 @@ def test_env(spec):
@pytest.mark.parametrize("spec", spec_list, ids=[spec.id for spec in spec_list])
def test_reset_info(spec):
with pytest.warns(None) as warnings:
with pytest.warns(None):
env = spec.make()
ob_space = env.observation_space
@@ -78,13 +78,12 @@ def test_reset_info(spec):
# Run a longer rollout on some environments
def test_random_rollout():
for env in [envs.make("CartPole-v1"), envs.make("FrozenLake-v1")]:
agent = lambda ob: env.action_space.sample()
ob = env.reset()
for _ in range(10):
assert env.observation_space.contains(ob)
a = agent(ob)
assert env.action_space.contains(a)
(ob, _reward, done, _info) = env.step(a)
action = env.action_space.sample()
assert env.action_space.contains(action)
(ob, _reward, done, _info) = env.step(action)
if done:
break
env.close()

View File

@@ -1,6 +1,3 @@
import numpy as np
import pytest
from gym.envs.toy_text.frozen_lake import generate_random_map

View File

@@ -2,9 +2,8 @@ import pytest
import gym
from gym import envs, error
from gym.envs import register, registration, registry, spec
from gym.envs import register, spec
from gym.envs.classic_control import cartpole
from gym.envs.registration import EnvSpec
class ArgumentEnv(gym.Env):

View File

@@ -569,20 +569,20 @@ def test_infinite_space(space):
# but floats are unbounded for infinite
if np.any(space.high != 0):
assert (
space.is_bounded("above") == False
space.is_bounded("above") is False
), "inf upper bound supposed to be unbounded"
else:
assert (
space.is_bounded("above") == True
space.is_bounded("above") is True
), "non-inf upper bound supposed to be bounded"
if np.any(space.low != 0):
assert (
space.is_bounded("below") == False
space.is_bounded("below") is False
), "inf lower bound supposed to be unbounded"
else:
assert (
space.is_bounded("below") == True
space.is_bounded("below") is True
), "non-inf lower bound supposed to be bounded"
# check for dtype

View File

@@ -67,7 +67,7 @@ def test_play_relevant_keys_no_mapping():
env = DummyPlayEnv()
env.spec = DummyEnvSpec("DummyPlayEnv")
with pytest.raises(MissingKeysToAction) as info:
with pytest.raises(MissingKeysToAction):
PlayableGame(env)
@@ -96,18 +96,18 @@ def test_keyboard_quit_event():
env = DummyPlayEnv()
game = PlayableGame(env, dummy_keys_to_action())
event = Event(pygame.KEYDOWN, {"key": pygame.K_ESCAPE})
assert game.running == True
assert game.running is True
game.process_event(event)
assert game.running == False
assert game.running is False
def test_pygame_quit_event():
env = DummyPlayEnv()
game = PlayableGame(env, dummy_keys_to_action())
event = Event(pygame.QUIT)
assert game.running == True
assert game.running is True
game.process_event(event)
assert game.running == False
assert game.running is False
def test_keyboard_relevant_keydown_event():

View File

@@ -167,7 +167,7 @@ def test_reset_timeout_async_vector_env(shared_memory):
try:
env = AsyncVectorEnv(env_fns, shared_memory=shared_memory)
env.reset_async()
observations = env.reset_wait(timeout=0.1)
env.reset_wait(timeout=0.1)
finally:
env.close(terminate=True)
@@ -178,7 +178,7 @@ def test_step_timeout_async_vector_env(shared_memory):
with pytest.raises(TimeoutError):
try:
env = AsyncVectorEnv(env_fns, shared_memory=shared_memory)
observations = env.reset()
env.reset()
env.step_async([0.1, 0.1, 0.3, 0.1])
observations, rewards, dones, _ = env.step_wait(timeout=0.1)
finally:
@@ -192,7 +192,7 @@ def test_reset_out_of_order_async_vector_env(shared_memory):
with pytest.raises(NoAsyncCallError):
try:
env = AsyncVectorEnv(env_fns, shared_memory=shared_memory)
observations = env.reset_wait()
env.reset_wait()
except NoAsyncCallError as exception:
assert exception.name == "reset"
raise
@@ -203,7 +203,7 @@ def test_reset_out_of_order_async_vector_env(shared_memory):
try:
env = AsyncVectorEnv(env_fns, shared_memory=shared_memory)
actions = env.action_space.sample()
observations = env.reset()
env.reset()
env.step_async(actions)
env.reset_async()
except NoAsyncCallError as exception:
@@ -248,7 +248,7 @@ def test_already_closed_async_vector_env(shared_memory):
with pytest.raises(ClosedEnvironmentError):
env = AsyncVectorEnv(env_fns, shared_memory=shared_memory)
env.close()
observations = env.reset()
env.reset()
@pytest.mark.parametrize("shared_memory", [True, False])

View File

@@ -65,8 +65,7 @@ def test_create_shared_memory(space, expected_type, n, ctx):
# Assert the length of the array
assert len(lhs[:]) == n * len(rhs[:])
# Assert the data type
assert type(lhs[0]) == type(rhs[0]) # noqa: E721
assert isinstance(lhs[0], type(rhs[0]))
else:
raise TypeError(f"Got unknown type `{type(lhs)}`.")
@@ -83,7 +82,7 @@ def test_create_shared_memory(space, expected_type, n, ctx):
def test_create_shared_memory_custom_space(n, ctx, space):
ctx = mp if (ctx is None) else mp.get_context(ctx)
with pytest.raises(CustomSpaceError):
shared_memory = create_shared_memory(space, n=n, ctx=ctx)
create_shared_memory(space, n=n, ctx=ctx)
@pytest.mark.parametrize(

View File

@@ -5,7 +5,7 @@ import pytest
from numpy.testing import assert_array_equal
from gym import Space
from gym.spaces import Box, Dict, Discrete, MultiDiscrete, Tuple
from gym.spaces import Box, Dict, MultiDiscrete, Tuple
from gym.vector.utils.spaces import batch_space, iterate
from tests.vector.utils import CustomSpace, assert_rng_equal, custom_spaces, spaces

View File

@@ -1,4 +1,3 @@
import gym
from gym.vector import VectorEnvWrapper, make

View File

@@ -5,7 +5,7 @@ import numpy as np
import pytest
import gym
from gym.spaces import Box, Dict, Discrete, Tuple
from gym.spaces import Box, Dict, Tuple
from gym.wrappers import FilterObservation, FlattenObservation

View File

@@ -1,4 +1,3 @@
import types
from typing import Optional
from unittest.mock import MagicMock
@@ -23,7 +22,9 @@ class DummyResetEnv(gym.Env):
metadata = {}
def __init__(self):
self.action_space = gym.spaces.Box(low=np.array([-1.0]), high=np.array([1.0]))
self.action_space = gym.spaces.Box(
low=np.array([-1.0]), high=np.array([1.0]), dtype=np.float64
)
self.observation_space = gym.spaces.Box(
low=np.array([-1.0]), high=np.array([1.0])
)
@@ -63,6 +64,7 @@ def test_autoreset_reset_info():
obs, info = env.reset(return_info=True)
assert ob_space.contains(obs)
assert isinstance(info, dict)
env.close()
@pytest.mark.parametrize("spec", spec_list, ids=[spec.id for spec in spec_list])
@@ -74,12 +76,10 @@ def test_make_autoreset_true(spec):
Note: This test assumes that all first-party environments will terminate in a finite
amount of time with random actions, which is true as of the time of adding this test.
"""
env = None
with pytest.warns(None) as warnings:
with pytest.warns(None):
env = spec.make(autoreset=True)
ob_space = env.observation_space
obs = env.reset(seed=0)
env.reset(seed=0)
env.action_space.seed(0)
env.unwrapped.reset = MagicMock(side_effect=env.unwrapped.reset)
@@ -90,22 +90,23 @@ def test_make_autoreset_true(spec):
assert isinstance(env, AutoResetWrapper)
assert env.unwrapped.reset.called
env.close()
@pytest.mark.parametrize("spec", spec_list, ids=[spec.id for spec in spec_list])
def test_make_autoreset_false(spec):
env = None
with pytest.warns(None) as warnings:
with pytest.warns(None):
env = spec.make(autoreset=False)
assert not isinstance(env, AutoResetWrapper)
env.close()
@pytest.mark.parametrize("spec", spec_list, ids=[spec.id for spec in spec_list])
def test_make_autoreset_default_false(spec):
env = None
with pytest.warns(None) as warnings:
with pytest.warns(None):
env = spec.make()
assert not isinstance(env, AutoResetWrapper)
env.close()
def test_autoreset_autoreset():
@@ -118,16 +119,16 @@ def test_autoreset_autoreset():
obs, reward, done, info = env.step(action)
assert obs == np.array([1])
assert reward == 0
assert done == False
assert done is False
assert info == {"count": 1}
obs, reward, done, info = env.step(action)
assert obs == np.array([2])
assert done == False
assert done is False
assert reward == 0
assert info == {"count": 2}
obs, reward, done, info = env.step(action)
assert obs == np.array([0])
assert done == True
assert done is True
assert reward == 1
assert info == {
"count": 0,
@@ -137,10 +138,11 @@ def test_autoreset_autoreset():
obs, reward, done, info = env.step(action)
assert obs == np.array([1])
assert reward == 0
assert done == False
assert done is False
assert info == {"count": 1}
obs, reward, done, info = env.step(action)
assert obs == np.array([2])
assert reward == 0
assert done == False
assert done is False
assert info == {"count": 2}
env.close()

View File

@@ -6,9 +6,8 @@ from gym.wrappers import ClipAction
def test_clip_action():
# mountaincar: action-based rewards
make_env = lambda: gym.make("MountainCarContinuous-v0")
env = make_env()
wrapped_env = ClipAction(make_env())
env = gym.make("MountainCarContinuous-v0")
wrapped_env = ClipAction(gym.make("MountainCarContinuous-v0"))
seed = 0

View File

@@ -1,8 +1,5 @@
import pytest
pytest.importorskip("gym.envs.atari")
import numpy as np
import pytest
import gym
from gym.wrappers import FrameStack
@@ -13,6 +10,9 @@ except ImportError:
lz4 = None
pytest.importorskip("gym.envs.atari")
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1", "Pong-v0"])
@pytest.mark.parametrize("num_stack", [2, 3, 4])
@pytest.mark.parametrize(

View File

@@ -1,6 +1,3 @@
import numpy as np
import pytest
import gym
from gym.wrappers import OrderEnforcing

View File

@@ -1,4 +1,3 @@
import numpy as np
import pytest
import gym

View File

@@ -1,15 +1,8 @@
import os
import shutil
import numpy as np
import pytest
import gym
from gym.wrappers import (
RecordEpisodeStatistics,
RecordVideo,
capped_cubic_video_schedule,
)
from gym.wrappers import capped_cubic_video_schedule
def test_record_video_using_default_trigger():

View File

@@ -1,6 +1,3 @@
import numpy as np
import pytest
import gym
from gym.wrappers import TimeLimit

View File

@@ -7,7 +7,9 @@ from gym.wrappers import TransformObservation
@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"])
def test_transform_observation(env_id):
affine_transform = lambda x: 3 * x + 2
def affine_transform(x):
return 3 * x + 2
env = gym.make(env_id)
wrapped_env = TransformObservation(
gym.make(env_id), lambda obs: affine_transform(obs)