MushroomRL/mushroom-rl

View on GitHub
mushroom_rl/core/dataset.py

Summary

Maintainability
D
2 days
Test Coverage
A
93%

File dataset.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np

from collections import defaultdict

import torch
Severity: Minor
Found in mushroom_rl/core/dataset.py - About 7 hrs to fix

    Dataset has 42 functions (exceeds 20 allowed). Consider refactoring.
    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)
    Severity: Minor
    Found in mushroom_rl/core/dataset.py - About 5 hrs to fix

      Function __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      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)
      
      
      Severity: Minor
      Found in mushroom_rl/core/dataset.py - About 1 hr to fix

      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

          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.
      Severity: Minor
      Found in mushroom_rl/core/dataset.py - About 1 hr to fix

      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

      There are no issues that match your filters.

      Category
      Status