File mujoco.py
has 531 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
import mujoco
import numpy as np
from dm_control import mjcf
from mushroom_rl.core import Environment, MDPInfo
from mushroom_rl.rl_utils.spaces import Box
MuJoCo
has 29 functions (exceeds 20 allowed). Consider refactoring. Wontfix
class MuJoCo(Environment):
"""
Class to create a Mushroom environment using the MuJoCo simulator.
"""
Function __init__
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Wontfix
def __init__(self, xml_files, actuation_spec, observation_spec, gamma, horizon, timestep=None,
n_substeps=1, n_intermediate_steps=1, additional_data_spec=None, collision_groups=None,
max_joint_vel=None, random_env_reset=True, **viewer_params):
"""
Constructor.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Wontfix
def __init__(self, xml_file, actuation_spec, observation_spec, gamma, horizon, timestep=None, n_substeps=1,
n_intermediate_steps=1, additional_data_spec=None, collision_groups=None, max_joint_vel=None,
**viewer_params):
"""
Constructor.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function step
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def step(self, action):
cur_obs = self._obs.copy()
action = self._preprocess_action(action)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _get_collision_force
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_collision_force(self, group1, group2):
"""
Returns the collision force and torques between the specified groups.
Args:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function reset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def reset(self, obs=None):
mujoco.mj_resetData(self._model, self._data)
if self._random_env_reset:
self._current_model_idx = np.random.randint(0, len(self._models))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"