qutip/qutip-qip

View on GitHub

Showing 161 of 175 total issues

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

if gate.name == "RX" and "RX" not in basis_1q:
qc_temp.gates.append(
Gate(
"RY",
gate.targets,
Severity: Major
Found in src/qutip_qip/circuit/circuit.py and 2 other locations - About 2 hrs to fix
src/qutip_qip/circuit/circuit.py on lines 650..673
src/qutip_qip/circuit/circuit.py on lines 678..701

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

elif gate.name == "RZ" and "RZ" not in basis_1q:
qc_temp.gates.append(
Gate(
"RX",
gate.targets,
Severity: Major
Found in src/qutip_qip/circuit/circuit.py and 2 other locations - About 2 hrs to fix
src/qutip_qip/circuit/circuit.py on lines 622..645
src/qutip_qip/circuit/circuit.py on lines 650..673

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

if np.abs(final_time - last_pulse_time) > min_step_size * 1.0e-6:
idling_tlist = self._process_idling_tlist(
pulse_mode, final_time, last_pulse_time, min_step_size
)
compiled_tlist[pulse_ind].append(idling_tlist)
Severity: Major
Found in src/qutip_qip/compiler/gatecompiler.py and 1 other location - About 2 hrs to fix
src/qutip_qip/compiler/gatecompiler.py on lines 237..243

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

if np.abs(start_time - last_pulse_time) > step_size * 1.0e-6:
idling_tlist = self._process_idling_tlist(
pulse_mode, start_time, last_pulse_time, step_size
)
compiled_tlist[pulse_ind].append(idling_tlist)
Severity: Major
Found in src/qutip_qip/compiler/gatecompiler.py and 1 other location - About 2 hrs to fix
src/qutip_qip/compiler/gatecompiler.py on lines 257..262

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

elif gate.name == "RY" and "RY" not in basis_1q:
qc_temp.gates.append(
Gate(
"RZ",
gate.targets,
Severity: Major
Found in src/qutip_qip/circuit/circuit.py and 2 other locations - About 2 hrs to fix
src/qutip_qip/circuit/circuit.py on lines 622..645
src/qutip_qip/circuit/circuit.py on lines 678..701

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

elif (start + end - i - i) == 2 and (
end - start + 1
) % 2 == 1:
temp.gates.append(Gate("SWAP", targets=[i, i + 1]))
temp.gates.append(
Severity: Major
Found in src/qutip_qip/circuit/circuit.py and 1 other location - About 1 hr to fix
src/qutip_qip/circuit/circuit.py on lines 764..797

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

Identical 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 if control
Severity: Major
Found in src/qutip_qip/circuit/circuit.py and 1 other location - About 1 hr to fix
src/qutip_qip/circuit/circuit.py on lines 809..823

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

Similar blocks of code found in 2 locations. Consider refactoring.
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 and 1 other location - About 1 hr to fix
src/qutip_qip/transpiler/chain.py on lines 104..114

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

elif (
N + start - end - i - i == 2
and (N - end + start + 1) % 2 == 1
):
temp.add_gate("SWAP", targets=[i, i + 1])
Severity: Major
Found in src/qutip_qip/transpiler/chain.py and 1 other location - About 1 hr to fix
src/qutip_qip/transpiler/chain.py on lines 225..238

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

elif (
N + start - end - i - i == 2
and (N - end + start + 1) % 2 == 1
):
temp.add_gate("SWAP", [i, i + 1])
Severity: Major
Found in src/qutip_qip/transpiler/chain.py and 1 other location - About 1 hr to fix
src/qutip_qip/transpiler/chain.py on lines 117..137

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

if wire == self._qwires + gate.classical_store:
self._render_strs["top_frame"][wire] += bar_conn
self._render_strs["mid_frame"][wire] += classical_conn
self._render_strs["bot_frame"][wire] += " " * len(bar_conn)
Severity: Major
Found in src/qutip_qip/circuit/text_renderer.py and 1 other location - About 1 hr to fix
src/qutip_qip/circuit/text_renderer.py on lines 370..373

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

for i, state in enumerate(states):
final = state
prob = probabilities[i]
_, final_probabilities = final_measurement.measurement_comp_basis(final)
np.testing.assert_allclose(initial_probabilities,
Severity: Major
Found in tests/test_qasm.py and 1 other location - About 1 hr to fix
tests/test_circuit.py on lines 578..587

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

for i, state in enumerate(states):
state_final = state
prob = probabilities[i]
_, final_probabilities = final_measurement.measurement_comp_basis(
state_final
Severity: Major
Found in tests/test_circuit.py and 1 other location - About 1 hr to fix
tests/test_qasm.py on lines 90..96

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

elif (start + end - i - i) == 2 and (
end - start + 1
) % 2 == 1:
qc_t.add_gate("SWAP", [i, i + 1])
qc_t.add_gate(gate.name, [i + 1, i + 2])
Severity: Major
Found in src/qutip_qip/transpiler/chain.py and 1 other location - About 1 hr to fix
src/qutip_qip/transpiler/chain.py on lines 225..232

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

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

xskip
+ self.style.gate_margin
+ self.style.gate_pad
- self._target_node_r / 2,
xskip
Severity: Major
Found in src/qutip_qip/circuit/mat_renderer.py and 1 other location - About 1 hr to fix
src/qutip_qip/circuit/mat_renderer.py on lines 465..473

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

[
xskip
+ self.style.gate_margin
+ self.style.gate_pad
- self._min_gate_width / 3,
Severity: Major
Found in src/qutip_qip/circuit/mat_renderer.py and 1 other location - About 1 hr to fix
src/qutip_qip/circuit/mat_renderer.py on lines 300..307

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