SforAiDl/genrl

View on GitHub

Showing 54 of 58 total issues

File actor_critic.py has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Tuple

import torch  # noqa
import torch.nn as nn  # noqa
from gym import spaces
Severity: Minor
Found in genrl/core/actor_critic.py - About 5 hrs to fix

    Function evolve has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def evolve(self, population):
            """
            Evolve the population of the network
    
            Args:
    Severity: Minor
    Found in genrl/evolutionary/genetic_hyperparam.py - About 3 hrs 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 train has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def train(self) -> List[float]:
            """
            general training loop for classical RL
            """
            timestep = 0
    Severity: Minor
    Found in genrl/trainers/classical.py - About 2 hrs 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 train has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def train(self) -> None:
            """Main training method"""
            if self.load_weights is not None or self.load_hyperparams is not None:
                self.load()
    
    
    Severity: Minor
    Found in genrl/trainers/offpolicy.py - About 2 hrs 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 tune_A2C has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def tune_A2C(trial):
        # Define hyperparameters that are relevant for training
        # Choose a suggestion type and range (float/int and log/uniform)
        lr_value = trial.suggest_float("lr_value", 1e-5, 1e-2, log=True)
        lr_policy = trial.suggest_float("lr_policy", 1e-5, 1e-2, log=True)
    Severity: Minor
    Found in examples/hyperparameters/optuna/a2c_cartpole-v0.py - About 2 hrs 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 evaluate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def evaluate(self, render: bool = False) -> None:
            """Evaluate performance of Agent
    
            Args:
                render (bool): Option to render the environment during evaluation
    Severity: Minor
    Found in genrl/trainers/base.py - About 2 hrs 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 objective has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def objective(trial):
        lr_value = trial.suggest_float("lr_value", 1e-6, 1e-1, log=True)
        lr_policy = trial.suggest_float("lr_policy", 1e-6, 1e-1, log=True)
        replay_size = trial.suggest_int("replay_size", 1e2, 1e5, log=True)
        max_ep_len = trial.suggest_int("max_ep_len", 1e3, 50000, log=True)
    Severity: Minor
    Found in examples/hyperparameters/optuna/td3_pendulum-v0.py - About 2 hrs 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 __init__ has 17 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in genrl/trainers/base.py - About 2 hrs to fix

      File vector_envs.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import multiprocessing as mp
      from abc import ABC, abstractmethod
      from copy import deepcopy
      from typing import Any, Iterator, List, Tuple
      
      
      Severity: Minor
      Found in genrl/environments/vec_env/vector_envs.py - About 2 hrs to fix

        Function train has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def train(self) -> None:
                """Main training method"""
                if self.load_weights is not None or self.load_hyperparams is not None:
                    self.load()
        
        
        Severity: Minor
        Found in genrl/trainers/onpolicy.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in genrl/trainers/classical.py - About 1 hr to fix

          Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in genrl/agents/deep/base/base.py - About 1 hr to fix

            Function run_experiment has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def run_experiment(args):
                start_time = datetime.now
                print(f"\nStarting experiment at {start_time():%d-%m-%y %H:%M:%S}\n")
                results = {}
            
            
            Severity: Minor
            Found in examples/run_cb.py - About 1 hr to fix

              Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Major
              Found in genrl/core/actor_critic.py - About 1 hr to fix

                Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(
                Severity: Major
                Found in genrl/core/actor_critic.py - About 1 hr to fix

                  Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                  Severity: Major
                  Found in genrl/core/actor_critic.py - About 1 hr to fix

                    Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(
                    Severity: Major
                    Found in genrl/trainers/offpolicy.py - About 1 hr to fix

                      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(
                      Severity: Major
                      Found in genrl/core/actor_critic.py - About 1 hr to fix

                        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(
                        Severity: Major
                        Found in genrl/core/actor_critic.py - About 1 hr to fix

                          Function worker has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def worker(parent_conn: mp.Pipe, child_conn: mp.Pipe, env: gym.Env):
                              """
                              Worker class to facilitate multiprocessing
                          
                              :param parent_conn: Parent connection of Pipe
                          Severity: Minor
                          Found in genrl/environments/vec_env/vector_envs.py - About 55 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language