The following issues were found

gym/wrappers/test_clip_action.py
9 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

import gym
from gym.wrappers import ClipAction


def test_clip_action():
    # mountaincar: action-based rewards
    make_env = lambda: gym.make("MountainCarContinuous-v0")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              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())


            

Reported by Pylint.

Variable name "d1" doesn't conform to snake_case naming style
Error

Line: 22 Column: 19

              
    actions = [[0.4], [1.2], [-0.3], [0.0], [-2.5]]
    for action in actions:
        obs1, r1, d1, _ = env.step(
            np.clip(action, env.action_space.low, env.action_space.high)
        )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)

            

Reported by Pylint.

Variable name "r1" doesn't conform to snake_case naming style
Error

Line: 22 Column: 15

              
    actions = [[0.4], [1.2], [-0.3], [0.0], [-2.5]]
    for action in actions:
        obs1, r1, d1, _ = env.step(
            np.clip(action, env.action_space.low, env.action_space.high)
        )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)

            

Reported by Pylint.

Variable name "r2" doesn't conform to snake_case naming style
Error

Line: 25 Column: 15

                      obs1, r1, d1, _ = env.step(
            np.clip(action, env.action_space.low, env.action_space.high)
        )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)
        assert d1 == d2

            

Reported by Pylint.

Variable name "d2" doesn't conform to snake_case naming style
Error

Line: 25 Column: 19

                      obs1, r1, d1, _ = env.step(
            np.clip(action, env.action_space.low, env.action_space.high)
        )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)
        assert d1 == d2

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 26
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          np.clip(action, env.action_space.low, env.action_space.high)
        )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)
        assert d1 == d2

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 27
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      )
        obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)
        assert d1 == d2

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 28
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      obs2, r2, d2, _ = wrapped_env.step(action)
        assert np.allclose(r1, r2)
        assert np.allclose(obs1, obs2)
        assert d1 == d2

            

Reported by Bandit.

gym/envs/mujoco/walker2d_v3.py
9 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils


DEFAULT_CAMERA_CONFIG = {
    "trackbodyid": 2,
    "distance": 4.0,
    "lookat": np.array((0.0, 0.0, 1.15)),

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              }


class Walker2dEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(
        self,
        xml_file="walker2d.xml",
        forward_reward_weight=1.0,
        ctrl_cost_weight=1e-3,

            

Reported by Pylint.

Too many instance attributes (8/7)
Error

Line: 14 Column: 1

              }


class Walker2dEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(
        self,
        xml_file="walker2d.xml",
        forward_reward_weight=1.0,
        ctrl_cost_weight=1e-3,

            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 15 Column: 5

              

class Walker2dEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(
        self,
        xml_file="walker2d.xml",
        forward_reward_weight=1.0,
        ctrl_cost_weight=1e-3,
        healthy_reward=1.0,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 47 Column: 5

                      mujoco_env.MujocoEnv.__init__(self, xml_file, 4)

    @property
    def healthy_reward(self):
        return (
            float(self.is_healthy or self._terminate_when_unhealthy)
            * self._healthy_reward
        )


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

                          * self._healthy_reward
        )

    def control_cost(self, action):
        control_cost = self._ctrl_cost_weight * np.sum(np.square(action))
        return control_cost

    @property
    def is_healthy(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 5

                      return control_cost

    @property
    def is_healthy(self):
        z, angle = self.sim.data.qpos[1:3]

        min_z, max_z = self._healthy_z_range
        min_angle, max_angle = self._healthy_angle_range


            

Reported by Pylint.

Variable name "z" doesn't conform to snake_case naming style
Error

Line: 59 Column: 9

              
    @property
    def is_healthy(self):
        z, angle = self.sim.data.qpos[1:3]

        min_z, max_z = self._healthy_z_range
        min_angle, max_angle = self._healthy_angle_range

        healthy_z = min_z < z < max_z

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 5

                      return is_healthy

    @property
    def done(self):
        done = not self.is_healthy if self._terminate_when_unhealthy else False
        return done

    def _get_obs(self):
        position = self.sim.data.qpos.flat.copy()

            

Reported by Pylint.

gym/utils/tests/test_seeding.py
8 issues
Unable to import 'gym'
Error

Line: 1 Column: 1

              from gym import error
from gym.utils import seeding


def test_invalid_seeds():
    for seed in [-1, "test"]:
        try:
            seeding.np_random(seed)
        except error.Error:

            

Reported by Pylint.

Unable to import 'gym.utils'
Error

Line: 2 Column: 1

              from gym import error
from gym.utils import seeding


def test_invalid_seeds():
    for seed in [-1, "test"]:
        try:
            seeding.np_random(seed)
        except error.Error:

            

Reported by Pylint.

Unused variable 'random'
Error

Line: 17 Column: 9

              
def test_valid_seeds():
    for seed in [0, 1]:
        random, seed1 = seeding.np_random(seed)
        assert seed == seed1

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from gym import error
from gym.utils import seeding


def test_invalid_seeds():
    for seed in [-1, "test"]:
        try:
            seeding.np_random(seed)
        except error.Error:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from gym.utils import seeding


def test_invalid_seeds():
    for seed in [-1, "test"]:
        try:
            seeding.np_random(seed)
        except error.Error:
            pass

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 12
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      except error.Error:
            pass
        else:
            assert False, "Invalid seed {} passed validation".format(seed)


def test_valid_seeds():
    for seed in [0, 1]:
        random, seed1 = seeding.np_random(seed)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 15 Column: 1

                          assert False, "Invalid seed {} passed validation".format(seed)


def test_valid_seeds():
    for seed in [0, 1]:
        random, seed1 = seeding.np_random(seed)
        assert seed == seed1

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              def test_valid_seeds():
    for seed in [0, 1]:
        random, seed1 = seeding.np_random(seed)
        assert seed == seed1

            

Reported by Bandit.

gym/envs/tests/test_kellycoinflip.py
8 issues
Unused variable 'reward'
Error

Line: 15 Column: 26

              
        while not done:
            action = int(env.wealth * 20)  # bet 20% of the wealth
            observation, reward, done, info = env.step(action)

        assert env.wealth == env.max_wealth

            

Reported by Pylint.

Unused variable 'observation'
Error

Line: 15 Column: 13

              
        while not done:
            action = int(env.wealth * 20)  # bet 20% of the wealth
            observation, reward, done, info = env.step(action)

        assert env.wealth == env.max_wealth

            

Reported by Pylint.

Unused variable 'info'
Error

Line: 15 Column: 40

              
        while not done:
            action = int(env.wealth * 20)  # bet 20% of the wealth
            observation, reward, done, info = env.step(action)

        assert env.wealth == env.max_wealth

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from gym.envs.toy_text.kellycoinflip import KellyCoinflipEnv


class TestKellyCoinflipEnv:
    @staticmethod
    def test_done_when_reaches_max_wealth():
        # https://github.com/openai/gym/issues/1266
        env = KellyCoinflipEnv()
        env.seed(1)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              from gym.envs.toy_text.kellycoinflip import KellyCoinflipEnv


class TestKellyCoinflipEnv:
    @staticmethod
    def test_done_when_reaches_max_wealth():
        # https://github.com/openai/gym/issues/1266
        env = KellyCoinflipEnv()
        env.seed(1)

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              from gym.envs.toy_text.kellycoinflip import KellyCoinflipEnv


class TestKellyCoinflipEnv:
    @staticmethod
    def test_done_when_reaches_max_wealth():
        # https://github.com/openai/gym/issues/1266
        env = KellyCoinflipEnv()
        env.seed(1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 5

              
class TestKellyCoinflipEnv:
    @staticmethod
    def test_done_when_reaches_max_wealth():
        # https://github.com/openai/gym/issues/1266
        env = KellyCoinflipEnv()
        env.seed(1)
        env.reset()
        done = False

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          action = int(env.wealth * 20)  # bet 20% of the wealth
            observation, reward, done, info = env.step(action)

        assert env.wealth == env.max_wealth

            

Reported by Bandit.

gym/wrappers/time_aware_observation.py
8 issues
Attribute 't' defined outside __init__
Error

Line: 31 Column: 9

                      return super(TimeAwareObservation, self).step(action)

    def reset(self, **kwargs):
        self.t = 0
        return super(TimeAwareObservation, self).reset(**kwargs)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from gym.spaces import Box
from gym import ObservationWrapper


class TimeAwareObservation(ObservationWrapper):
    r"""Augment the observation with current time step in the trajectory.

    .. note::

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 16 Column: 9

                  """

    def __init__(self, env):
        super(TimeAwareObservation, self).__init__(env)
        assert isinstance(env.observation_space, Box)
        assert env.observation_space.dtype == np.float32
        low = np.append(self.observation_space.low, 0.0)
        high = np.append(self.observation_space.high, np.inf)
        self.observation_space = Box(low, high, dtype=np.float32)

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
    def __init__(self, env):
        super(TimeAwareObservation, self).__init__(env)
        assert isinstance(env.observation_space, Box)
        assert env.observation_space.dtype == np.float32
        low = np.append(self.observation_space.low, 0.0)
        high = np.append(self.observation_space.high, np.inf)
        self.observation_space = Box(low, high, dtype=np.float32)


            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  def __init__(self, env):
        super(TimeAwareObservation, self).__init__(env)
        assert isinstance(env.observation_space, Box)
        assert env.observation_space.dtype == np.float32
        low = np.append(self.observation_space.low, 0.0)
        high = np.append(self.observation_space.high, np.inf)
        self.observation_space = Box(low, high, dtype=np.float32)

    def observation(self, observation):

            

Reported by Bandit.

Attribute name "t" doesn't conform to snake_case naming style
Error

Line: 27 Column: 9

                      return np.append(observation, self.t)

    def step(self, action):
        self.t += 1
        return super(TimeAwareObservation, self).step(action)

    def reset(self, **kwargs):
        self.t = 0
        return super(TimeAwareObservation, self).reset(**kwargs)

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 28 Column: 16

              
    def step(self, action):
        self.t += 1
        return super(TimeAwareObservation, self).step(action)

    def reset(self, **kwargs):
        self.t = 0
        return super(TimeAwareObservation, self).reset(**kwargs)

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 32 Column: 16

              
    def reset(self, **kwargs):
        self.t = 0
        return super(TimeAwareObservation, self).reset(**kwargs)

            

Reported by Pylint.

gym/wrappers/test_transform_observation.py
8 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import numpy as np

import gym
from gym.wrappers import TransformObservation


@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v0"])

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 14 Column: 27

                  affine_transform = lambda x: 3 * x + 2
    env = gym.make(env_id)
    wrapped_env = TransformObservation(
        gym.make(env_id), lambda obs: affine_transform(obs)
    )

    env.seed(0)
    wrapped_env.seed(0)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import numpy as np

import gym
from gym.wrappers import TransformObservation


@pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v0"])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              

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

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 22
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
    obs = env.reset()
    wrapped_obs = wrapped_env.reset()
    assert np.allclose(wrapped_obs, affine_transform(obs))

    action = env.action_space.sample()
    obs, reward, done, _ = env.step(action)
    wrapped_obs, wrapped_reward, wrapped_done, _ = wrapped_env.step(action)
    assert np.allclose(wrapped_obs, affine_transform(obs))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 27
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  action = env.action_space.sample()
    obs, reward, done, _ = env.step(action)
    wrapped_obs, wrapped_reward, wrapped_done, _ = wrapped_env.step(action)
    assert np.allclose(wrapped_obs, affine_transform(obs))
    assert np.allclose(wrapped_reward, reward)
    assert wrapped_done == done

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 28
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  obs, reward, done, _ = env.step(action)
    wrapped_obs, wrapped_reward, wrapped_done, _ = wrapped_env.step(action)
    assert np.allclose(wrapped_obs, affine_transform(obs))
    assert np.allclose(wrapped_reward, reward)
    assert wrapped_done == done

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 29
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  wrapped_obs, wrapped_reward, wrapped_done, _ = wrapped_env.step(action)
    assert np.allclose(wrapped_obs, affine_transform(obs))
    assert np.allclose(wrapped_reward, reward)
    assert wrapped_done == done

            

Reported by Bandit.

gym/wrappers/test_resize_observation.py
8 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import gym
from gym.wrappers import ResizeObservation

try:
    import atari_py
except ImportError:
    atari_py = None

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import gym
from gym.wrappers import ResizeObservation

try:
    import atari_py
except ImportError:
    atari_py = None

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              )
@pytest.mark.parametrize(
    "env_id", ["PongNoFrameskip-v0", "SpaceInvadersNoFrameskip-v0"]
)
@pytest.mark.parametrize("shape", [16, 32, (8, 5), [10, 7]])
def test_resize_observation(env_id, shape):
    env = gym.make(env_id)
    env = ResizeObservation(env, shape)


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 23
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  env = gym.make(env_id)
    env = ResizeObservation(env, shape)

    assert env.observation_space.shape[-1] == 3
    obs = env.reset()
    if isinstance(shape, int):
        assert env.observation_space.shape[:2] == (shape, shape)
        assert obs.shape == (shape, shape, 3)
    else:

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 26
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  assert env.observation_space.shape[-1] == 3
    obs = env.reset()
    if isinstance(shape, int):
        assert env.observation_space.shape[:2] == (shape, shape)
        assert obs.shape == (shape, shape, 3)
    else:
        assert env.observation_space.shape[:2] == tuple(shape)
        assert obs.shape == tuple(shape) + (3,)

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 27
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  obs = env.reset()
    if isinstance(shape, int):
        assert env.observation_space.shape[:2] == (shape, shape)
        assert obs.shape == (shape, shape, 3)
    else:
        assert env.observation_space.shape[:2] == tuple(shape)
        assert obs.shape == tuple(shape) + (3,)

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 29
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      assert env.observation_space.shape[:2] == (shape, shape)
        assert obs.shape == (shape, shape, 3)
    else:
        assert env.observation_space.shape[:2] == tuple(shape)
        assert obs.shape == tuple(shape) + (3,)

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 30
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      assert obs.shape == (shape, shape, 3)
    else:
        assert env.observation_space.shape[:2] == tuple(shape)
        assert obs.shape == tuple(shape) + (3,)

            

Reported by Bandit.

gym/envs/mujoco/pusher.py
8 issues
Unable to import 'mujoco_py'
Error

Line: 5 Column: 1

              from gym import utils
from gym.envs.mujoco import mujoco_env

import mujoco_py


class PusherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(self):
        utils.EzPickle.__init__(self)

            

Reported by Pylint.

Unused import mujoco_py
Error

Line: 5 Column: 1

              from gym import utils
from gym.envs.mujoco import mujoco_env

import mujoco_py


class PusherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(self):
        utils.EzPickle.__init__(self)

            

Reported by Pylint.

Parameters differ from overridden 'step' method
Error

Line: 13 Column: 5

                      utils.EzPickle.__init__(self)
        mujoco_env.MujocoEnv.__init__(self, "pusher.xml", 5)

    def step(self, a):
        vec_1 = self.get_body_com("object") - self.get_body_com("tips_arm")
        vec_2 = self.get_body_com("object") - self.get_body_com("goal")

        reward_near = -np.linalg.norm(vec_1)
        reward_dist = -np.linalg.norm(vec_2)

            

Reported by Pylint.

Attribute 'goal_pos' defined outside __init__
Error

Line: 34 Column: 9

                  def reset_model(self):
        qpos = self.init_qpos

        self.goal_pos = np.asarray([0, 0])
        while True:
            self.cylinder_pos = np.concatenate(
                [
                    self.np_random.uniform(low=-0.3, high=0, size=1),
                    self.np_random.uniform(low=-0.2, high=0.2, size=1),

            

Reported by Pylint.

Attribute 'cylinder_pos' defined outside __init__
Error

Line: 36 Column: 13

              
        self.goal_pos = np.asarray([0, 0])
        while True:
            self.cylinder_pos = np.concatenate(
                [
                    self.np_random.uniform(low=-0.3, high=0, size=1),
                    self.np_random.uniform(low=-0.2, high=0.2, size=1),
                ]
            )

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              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):
    def __init__(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              import mujoco_py


class PusherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(self):
        utils.EzPickle.__init__(self)
        mujoco_env.MujocoEnv.__init__(self, "pusher.xml", 5)

    def step(self, a):

            

Reported by Pylint.

Variable name "ob" doesn't conform to snake_case naming style
Error

Line: 23 Column: 9

                      reward = reward_dist + 0.1 * reward_ctrl + 0.5 * reward_near

        self.do_simulation(a, self.frame_skip)
        ob = self._get_obs()
        done = False
        return ob, reward, done, dict(reward_dist=reward_dist, reward_ctrl=reward_ctrl)

    def viewer_setup(self):
        self.viewer.cam.trackbodyid = -1

            

Reported by Pylint.

gym/envs/toy_text/kellycoinflip.py
7 issues
Unable to import 'scipy.stats'
Error

Line: 1 Column: 1

              from scipy.stats import genpareto, norm
import numpy as np

import gym
from gym import spaces
from gym.utils import seeding


def flip(edge, np_random):

            

Reported by Pylint.

TODO: this is boilerplate, is there any more elegant way to do this?
Error

Line: 135 Column: 3

                      # store the hyper-parameters for passing back into __init__() during resets so
        # the same hyper-parameters govern the next game's parameters, as the user
        # expects:
        # TODO: this is boilerplate, is there any more elegant way to do this?
        self.initial_wealth = float(initial_wealth)
        self.edge_prior_alpha = edge_prior_alpha
        self.edge_prior_beta = edge_prior_beta
        self.max_wealth_alpha = max_wealth_alpha
        self.max_wealth_m = max_wealth_m

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from scipy.stats import genpareto, norm
import numpy as np

import gym
from gym import spaces
from gym.utils import seeding


def flip(edge, np_random):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              from gym.utils import seeding


def flip(edge, np_random):
    return 1 if np_random.uniform() < edge else -1


class KellyCoinflipEnv(gym.Env):
    """The Kelly coinflip game is a simple gambling introduced by Haghani & Dewey 2016's

            

Reported by Pylint.

Too many instance attributes (10/7)
Error

Line: 13 Column: 1

                  return 1 if np_random.uniform() < edge else -1


class KellyCoinflipEnv(gym.Env):
    """The Kelly coinflip game is a simple gambling introduced by Haghani & Dewey 2016's
    'Rational Decision-Making Under Uncertainty: Observed Betting Patterns on a Biased
    Coin' (https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2856963), to test human
    decision-making in a setting like that of the stock market: positive expected value
    but highly stochastic; they found many subjects performed badly, often going broke,

            

Reported by Pylint.

Too many instance attributes (21/7)
Error

Line: 93 Column: 1

                      print("Current wealth: ", self.wealth, "; Rounds left: ", self.rounds)


class KellyCoinflipGeneralizedEnv(gym.Env):
    """The Generalized Kelly coinflip game is an extension by ArthurB & Gwern Branwen
    which expands the Kelly coinflip game MDP into a POMDP, where the 3 key parameters
    (edge, maximum wealth, and number of rounds) are unknown random variables drawn
    from 3 distributions: a Beta(7,3) for the coinflip edge 0-1, a N(300,25) the total
    number of rounds, and a Pareto(5,200) for the wealth cap. These distributions are

            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 118 Column: 5

              
    metadata = {"render.modes": ["human"]}

    def __init__(
        self,
        initial_wealth=25.0,
        edge_prior_alpha=7,
        edge_prior_beta=3,
        max_wealth_alpha=5.0,

            

Reported by Pylint.

gym/envs/mujoco/striker.py
7 issues
Parameters differ from overridden 'step' method
Error

Line: 14 Column: 5

                      self.strike_threshold = 0.1
        mujoco_env.MujocoEnv.__init__(self, "striker.xml", 5)

    def step(self, a):
        vec_1 = self.get_body_com("object") - self.get_body_com("tips_arm")
        vec_2 = self.get_body_com("object") - self.get_body_com("goal")
        self._min_strike_dist = min(self._min_strike_dist, np.linalg.norm(vec_2))

        if np.linalg.norm(vec_1) < self.strike_threshold:

            

Reported by Pylint.

Attribute '_strike_pos' defined outside __init__
Error

Line: 45 Column: 9

                  def reset_model(self):
        self._min_strike_dist = np.inf
        self._striked = False
        self._strike_pos = None

        qpos = self.init_qpos

        self.ball = np.array([0.5, -0.175])
        while True:

            

Reported by Pylint.

Attribute 'ball' defined outside __init__
Error

Line: 49 Column: 9

              
        qpos = self.init_qpos

        self.ball = np.array([0.5, -0.175])
        while True:
            self.goal = np.concatenate(
                [
                    self.np_random.uniform(low=0.15, high=0.7, size=1),
                    self.np_random.uniform(low=0.1, high=1.0, size=1),

            

Reported by Pylint.

Attribute 'goal' defined outside __init__
Error

Line: 51 Column: 13

              
        self.ball = np.array([0.5, -0.175])
        while True:
            self.goal = np.concatenate(
                [
                    self.np_random.uniform(low=0.15, high=0.7, size=1),
                    self.np_random.uniform(low=0.1, high=1.0, size=1),
                ]
            )

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env


class StrikerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(self):
        utils.EzPickle.__init__(self)
        self._striked = False

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              from gym.envs.mujoco import mujoco_env


class StrikerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
    def __init__(self):
        utils.EzPickle.__init__(self)
        self._striked = False
        self._min_strike_dist = np.inf
        self.strike_threshold = 0.1

            

Reported by Pylint.

Variable name "ob" doesn't conform to snake_case naming style
Error

Line: 34 Column: 9

                      reward = 3 * reward_dist + 0.1 * reward_ctrl + 0.5 * reward_near

        self.do_simulation(a, self.frame_skip)
        ob = self._get_obs()
        done = False
        return ob, reward, done, dict(reward_dist=reward_dist, reward_ctrl=reward_ctrl)

    def viewer_setup(self):
        self.viewer.cam.trackbodyid = 0

            

Reported by Pylint.