qutip/qutip-qip

View on GitHub

Showing 26 of 174 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 95 (exceeds 20 allowed). Consider refactoring.
Open

    def latex_code(self):
        """
        Generate the latex code for the circuit.

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

    def layout(self):
        """
        Layout the circuit
        """
        self._add_wire_labels()
Severity: Minor
Found in src/qutip_qip/circuit/text_renderer.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 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 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 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 end == gate.controls[0]:
                                temp.gates.append(
                                    Gate(gate.name, targets=[i], controls=[i + 1])
                                )
                            else:
    Severity: Major
    Found in src/qutip_qip/circuit/circuit.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/texrenderer.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 (
                                  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

            Function _update_qbridge has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

                def _update_qbridge(
                    self,
                    gate: Gate,
                    wire_list_control: List[int],
                    width: int,
            Severity: Minor
            Found in src/qutip_qip/circuit/text_renderer.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

            Avoid deeply nested control flow statements.
            Open

                                    if len(gate.targets) > 1:
                                        if gate.name == "SWAP":
                                            if _swap_processing:
                                                col.append(r" \qswap \qw")
                                                continue
            Severity: Major
            Found in src/qutip_qip/circuit/texrenderer.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 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
                  Severity
                  Category
                  Status
                  Source
                  Language