qutip/qutip-qip

View on GitHub

Showing 161 of 175 total issues

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

class Y(SingleQubitGate):
"""
Single-qubit Y gate.
 
Examples
Severity: Major
Found in src/qutip_qip/operations/gateclass.py and 2 other locations - About 1 hr to fix
src/qutip_qip/operations/gateclass.py on lines 430..449
src/qutip_qip/operations/gateclass.py on lines 474..493

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

class Z(SingleQubitGate):
"""
Single-qubit Z gate.
 
Examples
Severity: Major
Found in src/qutip_qip/operations/gateclass.py and 2 other locations - About 1 hr to fix
src/qutip_qip/operations/gateclass.py on lines 430..449
src/qutip_qip/operations/gateclass.py on lines 452..471

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

class X(SingleQubitGate):
"""
Single-qubit X gate.
 
Examples
Severity: Major
Found in src/qutip_qip/operations/gateclass.py and 2 other locations - About 1 hr to fix
src/qutip_qip/operations/gateclass.py on lines 452..471
src/qutip_qip/operations/gateclass.py on lines 474..493

Function canvas_plot has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

def canvas_plot(self) -> None:
"""
Plot the quantum circuit.
"""
 
 
Severity: Minor
Found in src/qutip_qip/circuit/mat_renderer.py - About 55 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 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 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

        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

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

                    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

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

                      if (
                      N + start - end - i - i == 1
                      and (N - end + start + 1) % 2 == 0
                      Severity: Major
                      Found in src/qutip_qip/transpiler/chain.py and 3 other locations - About 40 mins to fix
                      src/qutip_qip/transpiler/chain.py on lines 104..106
                      src/qutip_qip/transpiler/chain.py on lines 117..119
                      src/qutip_qip/transpiler/chain.py on lines 225..227

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

                      if (
                      N + start - end - i - i == 1
                      and (N - end + start + 1) % 2 == 0
                      Severity: Major
                      Found in src/qutip_qip/transpiler/chain.py and 3 other locations - About 40 mins to fix
                      src/qutip_qip/transpiler/chain.py on lines 117..119
                      src/qutip_qip/transpiler/chain.py on lines 219..221
                      src/qutip_qip/transpiler/chain.py on lines 225..227

                      Function _get_qobjevo_helper has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                      Open

                      def _get_qobjevo_helper(self, spline_kind, dims):
                      """
                      Please refer to `_Evoelement.get_qobjevo` for documentation.
                      """
                      mat = self.get_qobj(dims)
                      Severity: Minor
                      Found in src/qutip_qip/pulse.py - About 35 mins to fix

                      Function _concatenate_pulses has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                      Open

                      def _concatenate_pulses(
                      self, pulse_instructions, scheduled_start_time, num_controls
                      ):
                      """
                      Concatenate compiled pulses coefficients and tlist for each pulse.
                      Severity: Minor
                      Found in src/qutip_qip/compiler/gatecompiler.py - About 35 mins to fix

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

                      if len(gate.targets) == 1:
                      self._render_strs["top_frame"][wire] += top_frame
                      self._render_strs["mid_frame"][wire] += mid_connect_label
                      self._render_strs["bot_frame"][wire] += bot_frame
                      Severity: Major
                      Found in src/qutip_qip/circuit/text_renderer.py and 3 other locations - About 30 mins to fix
                      src/qutip_qip/circuit/text_renderer.py on lines 252..255
                      src/qutip_qip/circuit/text_renderer.py on lines 285..288
                      src/qutip_qip/circuit/text_renderer.py on lines 289..292
                      Severity
                      Category
                      Status
                      Source
                      Language