petspats/pyha

View on GitHub

Showing 164 of 164 total issues

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

def test_quadrant_iv():
    inputs = [0.234 - 0.92j]
    expect = [np.abs(inputs), np.angle(inputs) / np.pi]

    dut = ToPolar()
Severity: Major
Found in pyha/cores/cordic/to_polar/to_polar.py and 1 other location - About 3 hrs to fix
pyha/cores/cordic/to_polar/to_polar.py on lines 89..95

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

def test_quadrant_i():
    inputs = [0.234 + 0.92j]
    expect = [np.abs(inputs), np.angle(inputs) / np.pi]

    dut = ToPolar()
Severity: Major
Found in pyha/cores/cordic/to_polar/to_polar.py and 1 other location - About 3 hrs to fix
pyha/cores/cordic/to_polar/to_polar.py on lines 80..86

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

def test_quadrant_ii():
    inputs = [-0.234 + 0.92j]
    expect = [np.abs(inputs), np.angle(inputs) / np.pi]

    dut = ToPolar()
Severity: Major
Found in pyha/cores/cordic/to_polar/to_polar.py and 1 other location - About 3 hrs to fix
pyha/cores/cordic/to_polar/to_polar.py on lines 71..77

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

Function init_vhdl_type has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def init_vhdl_type(name, current_val, initial_val=None, parent=None):
    from pyha.conversion.conversion import RecursiveConverter
    if type(current_val) == int or type(current_val) == np.int64:
        return VHDLInt(name, current_val, initial_val, parent)
    elif type(current_val) == bool or type(current_val) == np.bool_:
Severity: Minor
Found in pyha/conversion/type_transforms.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 __setattr__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def __setattr__(self, name, value):
        """ Implements auto-resize feature, ie resizes all assigns to Sfix registers.
        Also implements the register behaviour i.e saves assigned value to shadow variable, that is later used by the '_pyha_update_registers' function.
        """
        if hasattr(self, '_pyha_is_initialization') or self._pyha_is_local() or not RegisterBehaviour.is_enabled():
Severity: Minor
Found in pyha/common/core.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 transform_resize_arguments has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def transform_resize_arguments(red_node):
    """ Replace 'wrap' -> fixed_wrap
        'saturate' -> fixed_saturate
        'truncate' -> fixed_truncate
        'round' -> fixed_round
Severity: Minor
Found in pyha/conversion/redbaron_transforms.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 range_to_vhdl has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def range_to_vhdl(self, pyrange):
        # this for was transforemed by 'redbaron_pyfor_to_vhdl'
        if str(self.iterator) == '\\_i_\\':
            return f"{pyrange}'range"

Severity: Minor
Found in pyha/conversion/redbaron_transforms.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 super_getattr has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def super_getattr(obj, attr, is_local=False):
    for part in attr.split('.'):
        if not is_local:
            if part == 'self' or part == 'self_next':
                continue
Severity: Minor
Found in pyha/conversion/redbaron_transforms.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

Complex has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Complex:
    """
    Complex number with ``.real`` and ``.imag`` elements. Default type is ``Complex(left=0, right=-17)``.

    :param val:
Severity: Minor
Found in pyha/common/complex.py - About 3 hrs to fix

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

        if dtype == Complex:
            input_signal = (np.random.normal(size=N) + np.random.normal(size=N) * 1j)
        else:
            input_signal = np.random.normal(size=N)
    Severity: Major
    Found in pyha/cores/filter/moving_average/moving_average.py and 1 other location - About 3 hrs to fix
    pyha/cores/filter/dc_removal/dc_removal.py on lines 75..78

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

    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

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

        if dtype == Complex:
            input_signal = (np.random.normal(size=N) + np.random.normal(size=N) * 1j)
        else:
            input_signal = np.random.normal(size=N)
    Severity: Major
    Found in pyha/cores/filter/dc_removal/dc_removal.py and 1 other location - About 3 hrs to fix
    pyha/cores/filter/moving_average/moving_average.py on lines 71..74

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

    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 convert has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert(red: Node, obj=None):
        set_convert_obj(obj)
    
        # delete all non convertable functions from redbaron AST
        # coding style is akward because of some redbaron bugs...
    Severity: Minor
    Found in pyha/conversion/redbaron_transforms.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 __call__ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(cls, *args, **kwargs):
            cls._pyha_is_initialization = True  # flag to avoid problems in __setattr__
            ret = super(Meta, cls).__call__(*args, **kwargs)
    
            if not SimulationRunning.is_enabled():  # local objects are simplified, they need no reset or register behaviour
    Severity: Minor
    Found in pyha/common/core.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 model has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def model(self, inp):
            def fft_model(inp):
                if self.INPUT_ORDERING == 'natural':
                    offset = self.LOCAL_FFT_SIZE // 2
                    twiddles = [W(i, self.LOCAL_FFT_SIZE) for i in range(offset)]
    Severity: Minor
    Found in pyha/cores/fft/fft_core/r2sdf.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_ghdl_cocotb has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_ghdl_cocotb(*inputs, converter=None, netlist=None, verbose=False):
        """ RTL simulator with GHDL and COCOTB. This requires that MODEL and PYHA simulations already ran.
        Inputs to the simulator are 'pipeline compensated' from PYHA simulation.
        """
        indata = []
    Severity: Minor
    Found in pyha/simulation/simulation_interface.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

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

    @pytest.mark.parametrize("avg_freq_axis", [2, 8, 16])
    @pytest.mark.parametrize("avg_time_axis", [1, 4, 8])
    @pytest.mark.parametrize("fft_size", [256, 128])
    @pytest.mark.parametrize("input_power", [0.1, 0.001])
    pyha/cores/fft/spectrogram/spectrogram.py on lines 88..91

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

    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

    @pytest.mark.parametrize("avg_freq_axis", [1, 2, 16])
    @pytest.mark.parametrize("avg_time_axis", [2, 4, 8])
    @pytest.mark.parametrize("fft_size", [128, 256])
    @pytest.mark.parametrize("input_power", [0.25, 0.001])
    Severity: Major
    Found in pyha/cores/fft/spectrogram/spectrogram.py and 1 other location - About 2 hrs to fix
    pyha/cores/fft/bitreversal_fftshift_avgpool/bitreversal_fftshift_avgpool.py on lines 133..136

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

    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 auto_resize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def auto_resize(target, value):
        if not AutoResize.is_enabled() or not isinstance(target, (Sfix, Complex)) or Sfix._float_mode.enabled:
            return value
        if target.bits is not None:
            right = value.right
    Severity: Minor
    Found in pyha/common/core.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

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

        inp = (np.random.uniform(-1, 1, size=64) + np.random.uniform(-1, 1, size=64) * 1j) * input_power
    Severity: Major
    Found in pyha/cores/fft/fft_power/fft_power.py and 1 other location - About 1 hr to fix
    pyha/cores/fft/fft_power/fft_power.py on lines 47..47

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

    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 __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

    Severity
    Category
    Status
    Source
    Language