q-optimize/c3

View on GitHub

Showing 160 of 330 total issues

Function eng_num has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def eng_num(val: float) -> Tuple[float, str]:
    """Convert a number to engineering notation by returning number and prefix."""
    if np.array(val).size > 1:
        return np.array(val), ""
    if np.isnan(val):
Severity: Minor
Found in c3/utils/utils.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 log_parameters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def log_parameters(self, evaluation, optim_status):
        if self.store_better_iterations_only:
            if optim_status["goal"] > self.best_iteration:
                return
            else:
Severity: Minor
Found in c3/optimizers/optimizer.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 RB has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def RB(
Severity: Major
Found in c3/libraries/fidelities.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if isinstance(data, dict):
            return {str(k): jsonify_list(v) for k, v in data.items()}
        elif isinstance(data, list):
            return [jsonify_list(v) for v in data]
        elif isinstance(data, tuple):
    Severity: Major
    Found in c3/c3objs.py - About 1 hr to fix

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

          def __init__(
              self, value, unit="undefined", min_val=None, max_val=None, symbol=r"\alpha"
          ):
              pref = 1.0
              value = np.array(value)
      Severity: Minor
      Found in c3/c3objs.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 get_Lindbladian has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_Lindbladian(self, dims):
              """
              Compute the Lindbladian, based on relaxation, dephasing constants and finite
              temperature.
      
      
      Severity: Minor
      Found in c3/libraries/chip.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 grid2D has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def grid2D(x_init, fun=None, fun_grad=None, grad_lookup=None, options={}):
          """
          Two dimensional scan of the function values around the initial point.
      
          Parameters
      Severity: Minor
      Found in c3/libraries/algorithms.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 initialise has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialise(self, drift_ham, lindbladian=False, init_temp=None):
              """
              Prepare the initial state of the system. At the moment finite temperature requires open system dynamics.
      
              Parameters
      Severity: Minor
      Found in c3/libraries/tasks.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in c3/signal/gates.py - About 50 mins to fix

        Function leakage_RB has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def leakage_RB(
        Severity: Major
        Found in c3/libraries/fidelities.py - About 50 mins to fix

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

              def __init__(
          Severity: Major
          Found in c3/libraries/chip.py - About 50 mins to fix

            Function orbit_infid has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def orbit_infid(
            Severity: Major
            Found in c3/libraries/fidelities.py - About 50 mins to fix

              Function state_transfer_infid_set has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def state_transfer_infid_set(
              Severity: Major
              Found in c3/libraries/fidelities.py - About 50 mins to fix

                Function tf_batch_propagate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def tf_batch_propagate(
                Severity: Major
                Found in c3/libraries/propagation.py - About 50 mins to fix

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

                      def __init__(
                  Severity: Minor
                  Found in c3/libraries/tasks.py - About 45 mins to fix

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

                        def __init__(
                            self,
                            name: str,
                            desc: str = None,
                            comment: str = None,
                    Severity: Minor
                    Found in c3/libraries/chip.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 quick_setup has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def quick_setup(self, chan, qubit_freq, gate_time, v2hz=1, sideband=None) -> None:
                    Severity: Minor
                    Found in c3/signal/gates.py - About 45 mins to fix

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

                          def __init__(
                      Severity: Minor
                      Found in c3/signal/pulse.py - About 45 mins to fix

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

                            def __init__(
                        Severity: Minor
                        Found in c3/model.py - About 45 mins to fix

                          Function tf_propagation_lind has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def tf_propagation_lind(h0, hks, col_ops, cflds_t, dt, history=False):
                          Severity: Minor
                          Found in c3/libraries/propagation.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language