sonntagsgesicht/timewave

View on GitHub

Showing 17 of 49 total issues

Function __init__ has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, producers, correlation=None, diffusion_driver=None):
        """

        :param list(GaussEvolutionProducer) producers: list of producers to evolve
        :param list(list(float)) or dict((StochasticProcess, StochasticProcess): float) or None correlation:
Severity: Minor
Found in timewave/stochasticproducer.py - About 6 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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *consumers):
        super(StackedConsumer, self).__init__()
        self.consumers = list()
        for c in consumers:
            if isinstance(c, (tuple, list)):
Severity: Minor
Found in timewave/consumers.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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *consumers):
        """
        initializer

        :param list(Consumer):
Severity: Minor
Found in timewave/consumers.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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *producers):
        """
        initializer

        :param list(Producer) or produces: list of producers to be used one after another
Severity: Minor
Found in timewave/producers.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 _fill_sparse_correlation has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def _fill_sparse_correlation(risk_factor_list, correlation):
    _correlation = dict() if correlation is None else dict(correlation)
    # fill sparse correlation matrix
    for rf_1 in risk_factor_list:
        for rf_2 in risk_factor_list:
Severity: Minor
Found in timewave/indexedmatrix.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 run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, grid=None, num_of_paths=2000, seed=0, num_of_workers=CPU_COUNT, profiling=False):
        """
        implements simulation

        :param list(date) grid: list of Monte Carlo grid dates
Severity: Minor
Found in timewave/engine.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 evolve has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def evolve(self, new_date):
        """
        evolve to the new process state at the next date

        :param date new_date: date or point in time of the new state
Severity: Minor
Found in timewave/stochasticproducer.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 __str__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def __str__(self):
        f = (lambda v: '%0.8f' % v if isinstance(v, (int, float)) else '')
        keys, values = list(self.keys()), list(map(f, list(self.values())))
        mk, mv = max(list(map(len, keys))), max(list(map(len, values)))
        res = [a.ljust(mk) + ' : ' + v.rjust(mv) for a, v in zip(keys, values)]
Severity: Minor
Found in timewave/stochasticconsumer.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 finalize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def finalize(self):
        """finalize for StochasticProcessStatisticsConsumer"""
        super(StochasticProcessStatisticsConsumer, self).finalize()

        class StochasticProcessStatistics(self.statistics):
Severity: Minor
Found in timewave/stochasticconsumer.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, transition=None, r_squared=1., start=None):
        """

        :param list transition: stochastic matrix of transition probabilities,
                                i.e. np.ndarray with shape=2 and sum of each line equal to 1
Severity: Minor
Found in timewave/stochasticprocess/markovchain.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

Avoid deeply nested control flow statements.
Open

                        if (rf_2, rf_1) in correlation:
                            if not correlation[rf_1, rf_2] == correlation[rf_2, rf_1]:
                                _ = rf_1, rf_2
                                raise ValueError("Correlation data must be symmetric. Input at [%d, %d] is not." % _)
                        i, j = drivers.index(rf_1), drivers.index(rf_2)
Severity: Major
Found in timewave/stochasticproducer.py - About 45 mins to fix

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

        def covariance(self, t):
            def _e_xy(prop_x, cum_prop_x, prop_y, cum_prop_y):
                b = list()
                for p, c in zip(prop_x, cum_prop_x):
                    b.append([max(0., min(c, d) - max(c - p, d - q)) for q, d in zip(prop_y, cum_prop_y)])
    Severity: Minor
    Found in timewave/stochasticprocess/markovchain.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

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

        def __init__(self, data, statistics=None, sample_len=0.5, sample_num=100, **expected):
    Severity: Minor
    Found in timewave/stochasticconsumer.py - About 35 mins to fix

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

          def __init__(self, alpha=.1, beta=.2, nu=.3, rho=-.2, start=.05):
      Severity: Minor
      Found in timewave/stochasticprocess/multifactor.py - About 35 mins to fix

        Function run has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def run(self, grid=None, num_of_paths=2000, seed=0, num_of_workers=CPU_COUNT, profiling=False):
        Severity: Minor
        Found in timewave/engine.py - About 35 mins to fix

          Function mop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def mop(A, B, op):
              C = [[0.0] * len(B[0]) for _ in range(len(A))]
              for i in range(len(A)):
                  for j in range(len(A[0])):
                      if op == '+':
          Severity: Minor
          Found in timewave/indexedmatrix.py - About 35 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 cholesky has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def cholesky(A):
              L = [[0.0] * len(A) for _ in range(len(A))]
              for i in range(len(A)):
                  for j in range(i + 1):
                      s = sum(L[i][k] * L[j][k] for k in range(j))
          Severity: Minor
          Found in timewave/indexedmatrix.py - About 25 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