alchemyst/Skogestad-Python

View on GitHub

Showing 668 of 668 total issues

File utils.py has 2314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
Created on Jan 27, 2012

@author: Carl Sandrock
Severity: Major
Found in robustcontrol/utils.py - About 6 days to fix

    File utilsplot.py has 1107 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    """
    Common features to plotting functions in this script
    
    Default parameters
    Severity: Major
    Found in robustcontrol/utilsplot.py - About 2 days to fix

      Function display_export_data has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
      Open

      def display_export_data(data, display_type, row_head, save=False, latex=False, width=None, sep='|'):
          """
          Create a table view of data. Data can also be exported for a csv file or
          LaTex tabular format. This function is ideal to display large amounts of
          data.
      Severity: Minor
      Found in robustcontrol/reporting.py - About 1 day 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_tf_coefficients has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_tf_coefficients(num, den, delays):
              """
              array-like: (numerator, denominator, delays)
              numerator, denominator, delays can either be in SISO form or MIMO form
              MIMO form e.g.:
      Severity: Minor
      Found in robustcontrol/InternalDelay.py - About 7 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 scaling has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

      def scaling(G_hat, e, u, input_type='symbolic', Gd_hat=None, d=None):
          """
          Receives symbolic matrix of plant and disturbance transfer functions
          as well as array of maximum deviations, scales plant variables according
          to eq () and ()
      Severity: Minor
      Found in robustcontrol/utils.py - About 7 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

      Cyclomatic complexity is too high in method from_tf_coefficients. (34)
      Open

          @staticmethod
          def from_tf_coefficients(num, den, delays):
              """
              array-like: (numerator, denominator, delays)
              numerator, denominator, delays can either be in SISO form or MIMO form
      Severity: Minor
      Found in robustcontrol/InternalDelay.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      File InternalDelay.py has 424 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      """
      Created on Apr 19, 2019
      
      @author: Darren Roos (http://github.com/darren-roos/)
      Severity: Minor
      Found in robustcontrol/InternalDelay.py - About 6 hrs to fix

        Cyclomatic complexity is too high in function display_export_data. (30)
        Open

        def display_export_data(data, display_type, row_head, save=False, latex=False, width=None, sep='|'):
            """
            Create a table view of data. Data can also be exported for a csv file or
            LaTex tabular format. This function is ideal to display large amounts of
            data.
        Severity: Minor
        Found in robustcontrol/reporting.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        Function rga_plot has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        def rga_plot(G, w_start=-2, w_end=2, axlim=None, points=1000, fig=0,
                     plot_type='elements', input_label=None, output_label=None):
            """
            Plots the relative gain interaction between each output and input pairing
        
        
        Severity: Minor
        Found in robustcontrol/utilsplot.py - About 5 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 PEAK_MIMO has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        def PEAK_MIMO(w_start, w_end, error_poles_direction, wr, deadtime_if=0):
            """
            This function is for multivariable system analysis of controllability.
            gives:
            minimum peak values on S and T with or without deadtime
        Severity: Minor
        Found in PEAK_MIMO.py - About 5 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 Chapter_05.py has 368 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from __future__ import division
        from __future__ import print_function
        
        import numpy as np
        import matplotlib.pyplot as plt
        Severity: Minor
        Found in robustcontrol/Chapter_05.py - About 4 hrs to fix

          Cyclomatic complexity is too high in function scaling. (22)
          Open

          def scaling(G_hat, e, u, input_type='symbolic', Gd_hat=None, d=None):
              """
              Receives symbolic matrix of plant and disturbance transfer functions
              as well as array of maximum deviations, scales plant variables according
              to eq () and ()
          Severity: Minor
          Found in robustcontrol/utils.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in function PEAK_MIMO. (22)
          Open

          def PEAK_MIMO(w_start, w_end, error_poles_direction, wr, deadtime_if=0):
              """
              This function is for multivariable system analysis of controllability.
              gives:
              minimum peak values on S and T with or without deadtime
          Severity: Minor
          Found in PEAK_MIMO.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Function multi_polylcm has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

          def multi_polylcm(P):
              roots_list = [i.r.tolist() for i in P]
              roots_by_mult = []
              lcm_roots_by_mult = []
              for roots in roots_list:
          Severity: Minor
          Found in robustcontrol/utils.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

          Cyclomatic complexity is too high in function rga_plot. (20)
          Open

          def rga_plot(G, w_start=-2, w_end=2, axlim=None, points=1000, fig=0,
                       plot_type='elements', input_label=None, output_label=None):
              """
              Plots the relative gain interaction between each output and input pairing
          
          
          Severity: Minor
          Found in robustcontrol/utilsplot.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Function mimo_bode has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          def mimo_bode(G, w_start=-2, w_end=2,
                        axlim=None, points=1000,
                        Kin=None, text=False, sv_all=False, legend_loc='best'):
              """
              Plots the max and min singular values of G and computes the crossover
          Severity: Minor
          Found in robustcontrol/utilsplot.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 tf_step has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          def tf_step(G, t_end=10, initial_val=0, points=1000,
                      constraint=None, Y=None, method='numeric'):
              """
              Validate the step response data of a transfer function by considering dead
              time and constraints. A unit step response is generated.
          Severity: Minor
          Found in robustcontrol/utils.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 PEAK_MIMO has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def PEAK_MIMO(w_start, w_end, error_poles_direction, wr, deadtime_if=0):
              """
              This function is for multivariable system analysis of controllability.
              gives:
              minimum peak values on S and T with or without deadtime
          Severity: Major
          Found in PEAK_MIMO.py - About 3 hrs to fix

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

                        for i in range(len(Poles_G)):
                            # Error_poles_direction is to to prevent the numerical
                            # method from breaking
                            [U, S, V] = np.linalg.svd(G(Poles_G[i]+error_poles_direction))
                            yp_direction[:, i] = U[:, 0]
            Severity: Major
            Found in PEAK_MIMO.py and 1 other location - About 3 hrs to fix
            PEAK_MIMO.py on lines 49..52

            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 70.

            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

                        for i in range(len(Zeros_G)):
            
                            [U, S, V] = np.linalg.svd(G(Zeros_G[i]+error_poles_direction))
                            yz_direction[:, i] = U[:, -1]
            Severity: Major
            Found in PEAK_MIMO.py and 1 other location - About 3 hrs to fix
            PEAK_MIMO.py on lines 54..58

            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 70.

            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

            Severity
            Category
            Status
            Source
            Language