mushroom_rl/core/dataset.py
File dataset.py
has 495 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import numpy as np
from collections import defaultdict
import torch
Dataset
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Dataset(Serializable):
def __init__(self, dataset_info, n_steps=None, n_episodes=None):
assert (n_steps is not None and n_episodes is None) or (n_steps is None and n_episodes is not None)
self._array_backend = ArrayBackend.get_array_backend(dataset_info.backend)
Function __init__
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def __init__(self, dataset_info, n_steps=None, n_episodes=None):
assert (n_steps is not None and n_episodes is None) or (n_steps is None and n_episodes is not None)
self._array_backend = ArrayBackend.get_array_backend(dataset_info.backend)
- 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 from_array
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def from_array(cls, states, actions, rewards, next_states, absorbings, lasts,
policy_state=None, policy_next_state=None, info=None, episode_info=None, theta_list=None,
horizon=None, gamma=0.99, backend='numpy', device=None):
"""
Creates a dataset of transitions from the provided arrays.
- 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"