TianyuDu/AnnEconForecast

View on GitHub

Showing 43 of 45 total issues

File stacked_lstm.py has 536 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This file contains the stacked version LSTM model for time series forecasting.
"""
import sys
from pprint import pprint
Severity: Major
Found in core/models/stacked_lstm.py - About 1 day to fix

    Function fit has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def fit(
            self,
            data: Dict[str, np.ndarray],
            ret: Union[None, List[str], "all"] = None,
            save_to_disk: bool = False
    Severity: Minor
    Found in core/models/stacked_lstm.py - About 4 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

    File optimizer.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Created: Dec. 24 2018
    The baseline genetic optimizer.
    """
    from typing import Callable, Dict, List, Tuple, Union, Iterable
    Severity: Minor
    Found in core/genetic/optimizer.py - About 3 hrs to fix

      Function core has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def core(
          profile_record: dict,
          raw_df: pd.DataFrame,
          verbose: bool,
          # set verbose=False when running hyper-parameter search.
      Severity: Minor
      Found in pytorch/lstm_controls.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 cross_over has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def cross_over(
              self,
              p1: Dict[str, object],
              p2: Dict[str, object]
          ) -> Tuple[dict]:
      Severity: Minor
      Found in core/genetic/tuner.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 mutate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def mutate(
              self,
              chromosome: Dict[str, object],
              mutate_prob: float = 0.05,
              factor_cap: Union[List[Union[float, int]], None] = [0.50, 2.0]
      Severity: Minor
      Found in core/genetic/optimizer.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 core has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      def core(
          profile_record: dict,
          raw_df: pd.DataFrame,
          verbose: bool,
              # set verbose=False when running hyper-parameter search.
      Severity: Minor
      Found in pytorch/nnar_controls.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 advanced_visualize has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def advanced_visualize(
          file_dir: str,  # Dataset directory.
          target: str,
          load_multi_ex: callable,
          CON_config: dict,
      Severity: Major
      Found in keras_based/exchange/core/tools/bokeh_visualize.py - About 2 hrs to fix

        Function core has 17 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def core(
        Severity: Major
        Found in pytorch/lstm_controls.py - About 2 hrs to fix

          Function core has 15 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def core(
          Severity: Major
          Found in pytorch/nnar_controls.py - About 1 hr to fix

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

            def exec_core(
                param: Dict[str, object],
                data: Dict[str, np.ndarray],
                prediction_checkpoints: Iterable[int] = [-1],
                verbose: bool = True
            Severity: Minor
            Found in core/models/stacked_lstm.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 train_op has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def train_op(
                optimizer,
                total_gen: int,
                elite: Union[int, float] = 1,
                write_to_disk: Union[None, str] = None
            Severity: Minor
            Found in core/genetic/control.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 cross_over has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def cross_over(
                    self,
                    p1: Dict[str, Union[str, float, int]],
                    p2: Dict[str, Union[str, float, int]]
                ) -> [dict, dict]:
            Severity: Minor
            Found in core/genetic/optimizer.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 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

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

                Function exec_core has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                def exec_core(
                    parameters: Dict[str, object],
                    data_collection: Dict[str, np.ndarray],
                    clip_grad: float=None,
                    prediction_checkpoints: Iterable[int]=[-1]
                Severity: Minor
                Found in core/models/baseline_lstm.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def __init__(
                            self,
                            series: pd.Series,
                            config: dict = {  # This is the default config for rapid testing.
                                "method": "diff",
                Severity: Minor
                Found in keras_based/exchange/core/containers/univariate_container.py - About 1 hr to fix

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

                      def _build_optimizer(self) -> None:
                          """
                          A helper func. building the optimizer in neural network.
                          """
                          if self.verbose:
                  Severity: Minor
                  Found in core/models/stacked_lstm.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

                  Function advanced_visualize has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def advanced_visualize(
                  Severity: Major
                  Found in keras_based/exchange/core/tools/bokeh_visualize.py - About 50 mins to fix

                    Function generate_supervised_learning has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate_supervised_learning(
                                self,
                                data: pd.DataFrame,
                                time_steps: int,
                                drop_target: bool=False) -> (
                    Severity: Minor
                    Found in keras_based/exchange/core/containers/multivariate_container.py - About 45 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