qutip/qutip-qip

View on GitHub

Showing 26 of 164 total issues

Function to_chain_structure has a Cognitive Complexity of 141 (exceeds 20 allowed). Consider refactoring.
Open

def to_chain_structure(qc, setup="linear"):
    """
    Method to resolve 2 qubit gates with non-adjacent control/s or target/s
    in terms of gates with adjacent interactions for linear/circular spin
    chain system.
Severity: Minor
Found in src/qutip_qip/transpiler/chain.py - About 2 days 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 latex_code has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
Open

    def latex_code(self):
        rows = []

        ops = self.gates
        col = []
Severity: Minor
Found in src/qutip_qip/circuit/circuit.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 _regs_processor has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
Open

    def _regs_processor(self, regs, reg_type):
        """
        Process register tokens: map them to the :class:`.QubitCircuit` indices
        of the respective registers.

Severity: Minor
Found in src/qutip_qip/qasm.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 circuit_to_qir has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

def circuit_to_qir(circuit, format, module_name="qutip_circuit"):
    """Converts a qubit circuit to its representation in QIR.

    Given a circuit acting on qubits, generates a representation of that
    circuit using Quantum Intermediate Representation (QIR).
Severity: Minor
Found in src/qutip_qip/qir.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

Function adjacent_gates has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

    def adjacent_gates(self):
        """
        Method to resolve two qubit gates with non-adjacent control/s or
        target/s in terms of gates with adjacent interactions.

Severity: Minor
Found in src/qutip_qip/circuit/circuit.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 resolve_gates has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
Open

    def resolve_gates(self, basis=["CNOT", "RX", "RY", "RZ"]):
        """
        Unitary matrix calculator for N qubits returning the individual
        steps as unitary matrices operating from left to right in the specified
        basis.
Severity: Minor
Found in src/qutip_qip/circuit/circuit.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 get_compact_qobj has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
Open

    def get_compact_qobj(self):
        """
        Get the compact :class:`qutip.Qobj` representation of the gate
        operator, ignoring the controls and targets.
        In the unitary representation,
Severity: Minor
Found in src/qutip_qip/operations/gateclass.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 _initialize_pass has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
Open

    def _initialize_pass(self):
        """
        Passes through the tokenized commands, create QasmGate objects for
        each user-defined gate, process register declarations.
        """
Severity: Minor
Found in src/qutip_qip/qasm.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 remove_gate_or_measurement has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

    def remove_gate_or_measurement(
        self, index=None, end=None, name=None, remove="first"
    ):
        """
        Remove a gate from a specific index or between two indexes or the
Severity: Minor
Found in src/qutip_qip/circuit/circuit.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 propagators has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

    def propagators(self, expand=True, ignore_measurement=False):
        """
        Propagator matrix calculator returning the individual
        steps as unitary matrices operating from left to right.

Severity: Minor
Found in src/qutip_qip/circuit/circuit.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 schedule has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

    def schedule(
        self,
        circuit,
        gates_schedule=False,
        return_cycles_list=False,
Severity: Minor
Found in src/qutip_qip/compiler/scheduler.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 run_state has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
Open

    def run_state(
        self,
        init_state=None,
        analytical=False,
        states=None,
Severity: Minor
Found in src/qutip_qip/device/processor.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

Avoid deeply nested control flow statements.
Open

                    if start + end - i - i == 1 and (end - start + 1) % 2 == 0:
                        # Apply required gate if control and target are
                        # adjacent to each other, provided |control-target|
                        # is even.
                        if end == gate.controls[0]:
Severity: Major
Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (
                            N + start - end - i - i == 1
                            and (N - end + start + 1) % 2 == 0
                        ):
                            temp.add_gate(gate.name, [i, i + 1])
    Severity: Major
    Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (self.reverse_states and n == self.N - 1) or (
                                  not self.reverse_states and n == 0
                              ):
                                  col.append(
                                      r" \multigate{%d}{%s} "
      Severity: Major
      Found in src/qutip_qip/circuit/circuit.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (
                                N + start - end - i - i == 1
                                and (N - end + start + 1) % 2 == 0
                            ):
                                if end == gate.controls[0]:
        Severity: Major
        Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if j < N - end - 2:
                                  if gate.name in ["CNOT", "CSIGN"]:
                                      qc_t.add_gate(
                                          gate.name,
                                          end + gate.targets[0],
          Severity: Major
          Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if j < N - end - 2:
                                    qc_t.add_gate(
                                        gate.name,
                                        [end + gate.targets[0], end + gate.targets[1]],
                                    )
            Severity: Major
            Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if end == gate.controls[0]:
                                          temp.gates.append(
                                              Gate(
                                                  gate.name,
                                                  targets=[i + 1],
              Severity: Major
              Found in src/qutip_qip/circuit/circuit.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if start + end - i - i == 1 and (end - start + 1) % 2 == 0:
                                        qc_t.add_gate(gate.name, [i, i + 1])
                                    elif (start + end - i - i) == 2 and (
                                        end - start + 1
                                    ) % 2 == 1:
                Severity: Major
                Found in src/qutip_qip/transpiler/chain.py - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language