petspats/pyha

View on GitHub
pyha/simulation/simulation_interface.py

Summary

Maintainability
D
2 days
Test Coverage

Function simulate has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

def simulate(model, *args, simulations=None, conversion_path=None, input_types=None,
             pipeline_flush='self.DELAY', trace=False):
    """
    Run simulations on model.

Severity: Minor
Found in pyha/simulation/simulation_interface.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

File simulation_interface.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import os
import shutil
import subprocess
import sys
Severity: Minor
Found in pyha/simulation/simulation_interface.py - About 4 hrs to fix

    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

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

    def convert_input_types(args, to_types=None, silence=False):
        if not silence:
            logger.info(f'Converting simulation inputs to hardware types...')
    
        def convert_arg(default_type, arg, i):
    Severity: Minor
    Found in pyha/simulation/simulation_interface.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 assert_sim_match has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def assert_sim_match(model, expected, *x, types=None, simulations=None, rtol=1e-04, atol=(2 ** -17) * 4, dir_path=None,
    Severity: Major
    Found in pyha/simulation/simulation_interface.py - About 1 hr to fix

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

      def sims_close(simulation_results, expected=None, rtol=1e-04, atol=(2 ** -17) * 4, skip_first_n=0):
          """
          TODO: LEGACY
          Compare the results of ``simulate`` function.
      
      
      Severity: Minor
      Found in pyha/simulation/simulation_interface.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 simulate has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def simulate(model, *args, simulations=None, conversion_path=None, input_types=None,
      Severity: Major
      Found in pyha/simulation/simulation_interface.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for input in tqdm(args, file=sys.stderr):
                                returns = model.main(*input)
                                returns = pyha_to_python(returns)
                                if returns is not None:
                                    valid_samples += 1
        Severity: Major
        Found in pyha/simulation/simulation_interface.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if pipeline_flush == 'auto' and valid_samples != len(out['MODEL']):
                                  args = list(args)
                                  logger.info(
                                      f'Flushing the pipeline to collect {len(out["MODEL"])} valid samples (currently have {valid_samples})')
                                  hardware_delay = 0
          Severity: Major
          Found in pyha/simulation/simulation_interface.py - About 45 mins to fix

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

            def assert_equals(simulation_results, expected=None, rtol=1e-04, atol=(2 ** -17) * 4, skip_first_n=0):
            Severity: Minor
            Found in pyha/simulation/simulation_interface.py - About 35 mins to fix

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

              def sims_close(simulation_results, expected=None, rtol=1e-04, atol=(2 ** -17) * 4, skip_first_n=0):
              Severity: Minor
              Found in pyha/simulation/simulation_interface.py - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status