qutip/qutip-qip

View on GitHub

Showing 161 of 175 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

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

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

def cs_gate(N=None, control=0, target=1):
"""Controlled S gate.
 
Returns
-------
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 6 hrs to fix
src/qutip_qip/operations/gates.py on lines 493..522

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

def cnot(N=None, control=0, target=1):
"""
Quantum object representing the CNOT gate.
 
Returns
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 6 hrs to fix
src/qutip_qip/operations/gates.py on lines 182..201

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

elif (
start + end - i - i == 2 and (end - start + 1) % 2 == 1
):
# Apply a swap between i and its adjacent gate,
# then the required gate if and then another swap
Severity: Major
Found in src/qutip_qip/transpiler/chain.py and 1 other location - About 6 hrs to fix
src/qutip_qip/transpiler/chain.py on lines 117..131

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

def iswap(N=None, targets=[0, 1]):
"""Quantum object representing the iSWAP gate.
 
Returns
-------
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 5 hrs to fix
src/qutip_qip/operations/gates.py on lines 645..673

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

def swap(N=None, targets=[0, 1]):
"""Quantum object representing the SWAP gate.
 
Returns
-------
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 5 hrs to fix
src/qutip_qip/operations/gates.py on lines 677..704

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if isinstance(device, DispersiveCavityQED):
num_ancilla = len(device.dims)-num_qubits
ancilla_indices = slice(0, num_ancilla)
extra = qutip.basis(device.dims[ancilla_indices], [0]*num_ancilla)
init_state = qutip.tensor(extra, state)
Severity: Major
Found in tests/test_device.py and 1 other location - About 3 hrs to fix
tests/test_device.py on lines 186..195

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if isinstance(device, DispersiveCavityQED):
num_ancilla = len(device.dims)-num_qubits
ancilla_indices = slice(0, num_ancilla)
extra = qutip.basis(device.dims[ancilla_indices], [0]*num_ancilla)
init_state = qutip.tensor(extra, state)
Severity: Major
Found in tests/test_device.py and 1 other location - About 3 hrs to fix
tests/test_device.py on lines 129..138

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

elif command[0] == "qreg":
groups = re.match(r"(.*)\[(.*)\]", "".join(command[1:]))
if groups:
qubit_name = groups.group(1)
num_regs = int(groups.group(2))
Severity: Major
Found in src/qutip_qip/qasm.py and 1 other location - About 3 hrs to fix
src/qutip_qip/qasm.py on lines 352..362

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

elif command[0] == "creg":
groups = re.match(r"(.*)\[(.*)\]", "".join(command[1:]))
if groups:
cbit_name = groups.group(1)
num_regs = int(groups.group(2))
Severity: Major
Found in src/qutip_qip/qasm.py and 1 other location - About 3 hrs to fix
src/qutip_qip/qasm.py on lines 340..350

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

return Qobj(
[
[1, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 3 hrs to fix
src/qutip_qip/operations/gates.py on lines 912..923

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

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

return Qobj(
[
[1, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
Severity: Major
Found in src/qutip_qip/operations/gates.py and 1 other location - About 3 hrs to fix
src/qutip_qip/operations/gates.py on lines 865..876

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

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

for i in range(self._qwires - 1, -1, -1):
file.write(self._render_strs["top_frame"][i] + "\n")
file.write(self._render_strs["mid_frame"][i] + "\n")
file.write(self._render_strs["bot_frame"][i] + "\n")
Severity: Major
Found in src/qutip_qip/circuit/text_renderer.py and 1 other location - About 2 hrs to fix
src/qutip_qip/circuit/text_renderer.py on lines 509..514

Identical blocks of code found in 2 locations. Consider refactoring.
Open

for i in range(
self._qwires + self._cwires - 1, self._qwires - 1, -1
):
file.write(self._render_strs["top_frame"][i] + "\n")
file.write(self._render_strs["mid_frame"][i] + "\n")
Severity: Major
Found in src/qutip_qip/circuit/text_renderer.py and 1 other location - About 2 hrs to fix
src/qutip_qip/circuit/text_renderer.py on lines 504..507

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
Severity
Category
Status
Source
Language