petspats/pyha

View on GitHub
pyha/common/fixed_point.py

Summary

Maintainability
D
2 days
Test Coverage

Sfix has 39 functions (exceeds 20 allowed). Consider refactoring.
Open

class Sfix:
    """
    Signed fixed-point type. Default fixed-point format in Pyha is ``Sfix(left=0, right=-17)`` (17 fractional bits + sign)
    , representing values in range [-1, 1] ``(2**0)`` with resolution of 0.0000076 ``(2**-17)``.

Severity: Minor
Found in pyha/common/fixed_point.py - About 5 hrs to fix

    File fixed_point.py has 378 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import math
    
    import numpy as np
    
    
    Severity: Minor
    Found in pyha/common/fixed_point.py - About 5 hrs to fix

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

          def __init__(self, val=0.0, left=None, right=None, overflow_style='wrap',
                       round_style='truncate', init_only=False, wrap_is_ok=False, signed=True, bits=None, size_res=None, upper_bits=None):
      
              self.upper_bits = upper_bits
              self.bits = bits
      Severity: Minor
      Found in pyha/common/fixed_point.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__(self, val=0.0, left=None, right=None, overflow_style='wrap',
      Severity: Major
      Found in pyha/common/fixed_point.py - About 1 hr to fix

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

        def resize(fix: Sfix, left=0, right=-17, size_res=None, overflow_style='wrap', round_style='truncate', wrap_is_ok=False,
        Severity: Major
        Found in pyha/common/fixed_point.py - About 1 hr to fix

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

              def _size_add(self, other):
                  """ Size rules for add/sub operation. Handles the 'None'(lazy) cases. """
                  if self.left is None and other.left is None:
                      left = None
                  elif self.left is None:
          Severity: Minor
          Found in pyha/common/fixed_point.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 __mul__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def __mul__(self, other):
                  other = self._convert_other_operand(other)
          
                  if self.left is None and other.left is None:
                      left = None
          Severity: Minor
          Found in pyha/common/fixed_point.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 resize has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def resize(self, left=0, right=0, type=None, overflow_style='wrap', round_style='truncate', wrap_is_ok=False,
          Severity: Major
          Found in pyha/common/fixed_point.py - About 50 mins to fix

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

                def saturate(self):
                    old = self.val
                    if self.val > self.max_representable():
                        self.val = self.max_representable()
                    elif self.val < self.min_representable():
            Severity: Minor
            Found in pyha/common/fixed_point.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 wrap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def wrap(self):
                    fmin = self.min_representable()
                    fmax = 2 ** self.left  # no need to substract minimal step, 0.9998... -> 1.0 will still be wrapped as max bit pattern
                    new_val = (self.val - fmin) % (fmax - fmin) + fmin
                    if not self.wrap_is_ok and self.signed:
            Severity: Minor
            Found in pyha/common/fixed_point.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 resize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def resize(fix: Sfix, left=0, right=-17, size_res=None, overflow_style='wrap', round_style='truncate', wrap_is_ok=False,
                       signed=None) -> Sfix:
                """
                Resize fixed point number.
            
            
            Severity: Minor
            Found in pyha/common/fixed_point.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

            There are no issues that match your filters.

            Category
            Status