TianyuDu/AnnEconForecast

View on GitHub

Showing 45 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    Severity: Major
    Found in hps_configs/mac_config.py and 1 other location - About 5 hrs to fix
    hps_configs/template.py on lines 0..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 90.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    Severity: Major
    Found in hps_configs/template.py and 1 other location - About 5 hrs to fix
    hps_configs/mac_config.py on lines 0..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 90.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

                  Severity
                  Category
                  Status
                  Source
                  Language