Skip to content

Commit 66444cd

Browse files
committed
Fix ty errors
1 parent ebd42ce commit 66444cd

11 files changed

Lines changed: 110 additions & 110 deletions

File tree

src/mqt/qecc/cc_decoder/stim_interface/color_code_stim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def gen_stim_circuit_memory_experiment(
8989
"""Generate a stim circuit for a memory experiment on the 2D color code."""
9090
data_qubits = range(len(pcm[0]))
9191
circuit = stim.Circuit()
92-
circuit.append("R", data_qubits) # ty: ignore[no-matching-overload]
92+
circuit.append("R", data_qubits)
9393

9494
# initialization
9595
circuit = add_checks_one_round(pcm, circuit, False, 0)

src/mqt/qecc/circuit_synthesis/cat_states.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def cat_state_line(w: int) -> stim.Circuit:
7373
noisy stim circuit preparing the cat state
7474
"""
7575
circ = stim.Circuit()
76-
circ.append("H", [0]) # ty: ignore[no-matching-overload]
76+
circ.append("H", [0])
7777
for i in reversed(range(1, w)):
78-
circ.append("CX", [0, i]) # ty: ignore[no-matching-overload]
78+
circ.append("CX", [0, i])
7979
return circ
8080

8181

@@ -153,7 +153,7 @@ def sample_cat_state(
153153
circ = self._get_noisy_circ(p)
154154
# Final, *noise-free* measurement of data qubits
155155
circ.append("TICK") # ty: ignore[invalid-argument-type]
156-
circ.append("MR", list(range(self.w1))) # ty: ignore[no-matching-overload]
156+
circ.append("MR", list(range(self.w1)))
157157

158158
if batch_size is None:
159159
batch_size = n_samples
@@ -290,8 +290,8 @@ def _add_qubit_initializations(circ: stim.Circuit) -> stim.Circuit:
290290
hadamard_qubits.update(t.value for t in gate.targets_copy())
291291

292292
with_inits = with_inits[::-1]
293-
with_inits.append("RX", list(hadamard_qubits - is_initialized)) # ty: ignore[no-matching-overload]
294-
with_inits.append("R", [q for q in range(circ.num_qubits) if q not in hadamard_qubits and q not in is_initialized]) # ty: ignore[no-matching-overload]
293+
with_inits.append("RX", list(hadamard_qubits - is_initialized))
294+
with_inits.append("R", [q for q in range(circ.num_qubits) if q not in hadamard_qubits and q not in is_initialized])
295295
return with_inits[::-1]
296296

297297

@@ -417,14 +417,14 @@ def fault_gens_from_circuit(circ: stim.Circuit) -> list[int]:
417417

418418
def _ft_w_4_cat_state() -> tuple[stim.Circuit, list[tuple[list[int], list[int]]]]:
419419
circ = stim.Circuit()
420-
circ.append("RX", [4]) # ty: ignore[no-matching-overload]
421-
circ.append("R", [0, 1, 2, 3]) # ty: ignore[no-matching-overload]
422-
circ.append("CX", [4, 0]) # ty: ignore[no-matching-overload]
423-
circ.append("CX", [0, 1]) # ty: ignore[no-matching-overload]
424-
circ.append("CX", [1, 2]) # ty: ignore[no-matching-overload]
425-
circ.append("CX", [2, 3]) # ty: ignore[no-matching-overload]
426-
circ.append("CX", [3, 4]) # ty: ignore[no-matching-overload]
427-
circ.append("MR", [4]) # ty: ignore[no-matching-overload]
420+
circ.append("RX", [4])
421+
circ.append("R", [0, 1, 2, 3])
422+
circ.append("CX", [4, 0])
423+
circ.append("CX", [0, 1])
424+
circ.append("CX", [1, 2])
425+
circ.append("CX", [2, 3])
426+
circ.append("CX", [3, 4])
427+
circ.append("MR", [4])
428428
return circ, [([4], [0, 1, 2, 3])]
429429

430430

@@ -490,10 +490,10 @@ def _recurse(w1: int, w2: int) -> tuple[stim.Circuit, list[tuple[list[int], list
490490
new_measurements = []
491491
for i in range(n_meas):
492492
anc = circ.num_qubits
493-
circ.append("R", [anc]) # ty: ignore[no-matching-overload]
494-
circ.append("CX", [i, anc]) # ty: ignore[no-matching-overload]
495-
circ.append("CX", [i + w1, anc]) # ty: ignore[no-matching-overload]
496-
circ.append("MR", [anc]) # ty: ignore[no-matching-overload]
493+
circ.append("R", [anc])
494+
circ.append("CX", [i, anc])
495+
circ.append("CX", [i + w1, anc])
496+
circ.append("MR", [anc])
497497
new_measurements.append(anc)
498498

499499
data_to_flip = list(range(w1)) if w1 < w2 else list(range(w1, w1 + w2))
@@ -629,7 +629,7 @@ def simulate_recursive_cat_construction(
629629
circ_run += circ_base
630630
circ_run.append("TICK") # ty: ignore[invalid-argument-type]
631631
# measure data at the end
632-
circ_run.append("MR", list(range(w))) # ty: ignore[no-matching-overload]
632+
circ_run.append("MR", list(range(w)))
633633
data_cols_start = len(meas_index_of_qubit) # data bits are at the end
634634

635635
circ_noisy = circ_run

src/mqt/qecc/circuit_synthesis/circuit_utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def relabel_qubits(circ: Circuit, qubit_mapping: dict[int, int] | int) -> Circui
4545
relabelled_qubits = [qubit_mapping[q.value] for q in op.targets_copy()]
4646
else:
4747
relabelled_qubits = [q.value + qubit_mapping for q in op.targets_copy()]
48-
new_circ.append(op.name, relabelled_qubits) # ty: ignore[no-matching-overload]
48+
new_circ.append(op.name, relabelled_qubits)
4949
return new_circ
5050

5151

@@ -67,10 +67,10 @@ def qiskit_to_stim_circuit(qc: QuantumCircuit) -> Circuit:
6767
op = gate.operation.name
6868
qubit = qc.find_bit(gate.qubits[0])[0]
6969
if op in single_qubit_gate_map:
70-
stim_circuit.append(single_qubit_gate_map[op], [qubit]) # ty: ignore[no-matching-overload]
70+
stim_circuit.append(single_qubit_gate_map[op], [qubit])
7171
elif op == "cx":
7272
target = qc.find_bit(gate.qubits[1])[0]
73-
stim_circuit.append("CX", [qubit, target]) # ty: ignore[no-matching-overload]
73+
stim_circuit.append("CX", [qubit, target])
7474
elif op == "barrier":
7575
stim_circuit.append("TICK") # ty: ignore[invalid-argument-type]
7676
else:
@@ -148,9 +148,9 @@ def collect_circuit_layers(circ: Circuit, scheduling_method: str = "asap") -> li
148148
for instr in circ:
149149
assert isinstance(instr, CircuitInstruction)
150150
for grp in instr.target_groups():
151-
qubits = [q.qubit_value for q in grp]
152-
circ_copy.append(instr.name, qubits) # ty: ignore[no-matching-overload]
153-
circ_copy.append("TICK", []) # ty: ignore[no-matching-overload]
151+
qubits = [q.qubit_value for q in grp if q.qubit_value is not None]
152+
circ_copy.append(instr.name, qubits)
153+
circ_copy.append("TICK", [])
154154

155155
if scheduling_method == "alap":
156156
circ_copy = circ_copy[::-1] # Reverse the circuit for ALAP scheduling
@@ -181,7 +181,7 @@ def collect_circuit_layers(circ: Circuit, scheduling_method: str = "asap") -> li
181181

182182
# Check if any qubit from this instruction is already used in the layer
183183
if not any(qubit_layer_used[q] for q in qubits):
184-
layer.append(instr.name, qubits) # ty: ignore[no-matching-overload]
184+
layer.append(instr.name, qubits)
185185
instr_to_delete.append(idx) # Mark this instruction for removal
186186

187187
# Mark the qubits used in this instruction
@@ -229,7 +229,7 @@ def remove_single_qubit_gates(circ: Circuit) -> Circuit:
229229
assert isinstance(op, CircuitInstruction)
230230
if all(len(grp) == 1 for grp in op.target_groups()):
231231
continue
232-
new_circ.append(op.name, _get_qubit_values(op)) # ty: ignore[no-matching-overload]
232+
new_circ.append(op.name, _get_qubit_values(op))
233233
return new_circ
234234

235235

@@ -246,7 +246,7 @@ def remove_swap_gates(circ: Circuit) -> Circuit:
246246
for op in circ:
247247
if op.name == "SWAP":
248248
continue
249-
new_circ.append(op.name, _get_qubit_values(op)) # ty: ignore[no-matching-overload]
249+
new_circ.append(op.name, _get_qubit_values(op))
250250
return new_circ
251251

252252

src/mqt/qecc/circuit_synthesis/circuits.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def to_stim_circuit(self, with_resets: bool = True) -> stim.Circuit:
179179
result = stim.Circuit()
180180

181181
for qubit, basis in self._initializations.items():
182-
result.append("R" + basis, [qubit]) # ty: ignore[no-matching-overload]
182+
result.append("R" + basis, [qubit])
183183

184184
result += self._circ
185185

@@ -387,10 +387,10 @@ def to_stim_circuit(self, with_resets: bool = True) -> stim.Circuit:
387387

388388
if with_resets:
389389
for qubit, basis in self._initializations.items():
390-
stim_circuit.append("R" + basis, [qubit]) # ty: ignore[no-matching-overload]
390+
stim_circuit.append("R" + basis, [qubit])
391391

392392
if self.cnots:
393-
stim_circuit.append("CX", [qubit for pair in self.cnots for qubit in pair]) # ty: ignore[no-matching-overload]
393+
stim_circuit.append("CX", [qubit for pair in self.cnots for qubit in pair])
394394

395395
return stim_circuit
396396

src/mqt/qecc/circuit_synthesis/encoding.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,27 +456,27 @@ def cz_var(depth: int, q1: int, q2: int) -> z3.BoolRef:
456456
# Single-qubit gates.
457457
for q in range(n):
458458
if model_bool(model, h_gate[depth][q]):
459-
reduction.append("H", [q]) # ty: ignore[no-matching-overload]
459+
reduction.append("H", [q])
460460
elif model_bool(model, s_gate[depth][q]):
461-
reduction.append("S", [q]) # ty: ignore[no-matching-overload]
461+
reduction.append("S", [q])
462462
elif model_bool(model, sqrt_x_gate[depth][q]):
463-
reduction.append("SQRT_X", [q]) # ty: ignore[no-matching-overload]
463+
reduction.append("SQRT_X", [q])
464464

465465
# Two-qubit gates.
466466
for (control, target), gate in cx_gate[depth].items():
467467
if model_bool(model, gate):
468-
reduction.append("CX", [control, target]) # ty: ignore[no-matching-overload]
468+
reduction.append("CX", [control, target])
469469

470470
for (q1, q2), gate in cz_gate[depth].items():
471471
if model_bool(model, gate):
472-
reduction.append("CZ", [q1, q2]) # ty: ignore[no-matching-overload]
472+
reduction.append("CZ", [q1, q2])
473473

474474
# Normalize terminal X-pivot ancillas to Z-pivot ancillas.
475475
# In the final encoder this becomes initial H preparation of those ancillas.
476476
x_pivot_ancillas: list[int] = [q for q in range(n) if model_bool(model, x_pivot[q])]
477477

478478
if x_pivot_ancillas:
479-
reduction.append("H", x_pivot_ancillas) # ty: ignore[no-matching-overload]
479+
reduction.append("H", x_pivot_ancillas)
480480

481481
# Extract which physical qubits carry the input logical qubits.
482482
encoding_qubits: list[int] = []
@@ -496,7 +496,7 @@ def cz_var(depth: int, q1: int, q2: int) -> z3.BoolRef:
496496
encoder_circuit = stim.Circuit()
497497

498498
if ancilla_qubits:
499-
encoder_circuit.append("RZ", ancilla_qubits) # ty: ignore[no-matching-overload]
499+
encoder_circuit.append("RZ", ancilla_qubits)
500500

501501
encoder_circuit += reduction.inverse()
502502

@@ -533,11 +533,11 @@ def cz_var(depth: int, q1: int, q2: int) -> z3.BoolRef:
533533

534534
for q, (xv, zv) in enumerate(zip(x_correction, z_correction, strict=False)):
535535
if xv == 1 and zv == 1:
536-
encoder_circuit.append("Y", [q]) # ty: ignore[no-matching-overload]
536+
encoder_circuit.append("Y", [q])
537537
elif xv == 1:
538-
encoder_circuit.append("X", [q]) # ty: ignore[no-matching-overload]
538+
encoder_circuit.append("X", [q])
539539
elif zv == 1:
540-
encoder_circuit.append("Z", [q]) # ty: ignore[no-matching-overload]
540+
encoder_circuit.append("Z", [q])
541541

542542
return CliffordIsometry.from_stim_circuit(encoder_circuit)
543543

@@ -744,7 +744,7 @@ def gottesman_encoding_circuit(tableau: StabilizerTableau | Sequence[str]) -> Cl
744744
z_part[row] = t
745745

746746
if x_part[row][column] == 0:
747-
circ.append("H", [column]) # ty: ignore[no-matching-overload]
747+
circ.append("H", [column])
748748
t = x_part[:, column].copy()
749749
x_part[:, column] = z_part[:, column]
750750
z_part[:, column] = t
@@ -753,26 +753,26 @@ def gottesman_encoding_circuit(tableau: StabilizerTableau | Sequence[str]) -> Cl
753753
for q in np.where(x_part[row])[0]:
754754
if q == column:
755755
continue
756-
circ.append("CX", [column, q]) # ty: ignore[no-matching-overload]
756+
circ.append("CX", [column, q])
757757
x_part[:, q] ^= x_part[:, column]
758758
z_part[:, column] ^= z_part[:, q]
759759

760760
if z_part[row][column] == 1:
761-
circ.append("S", [column]) # ty: ignore[no-matching-overload]
761+
circ.append("S", [column])
762762
z_part[:, column] ^= x_part[:, column]
763763

764764
for q in np.where(z_part[row])[0]:
765765
if q == column:
766766
continue
767-
circ.append("CZ", [column, q]) # ty: ignore[no-matching-overload]
767+
circ.append("CZ", [column, q])
768768
z_part[:, q] ^= x_part[:, column]
769769
z_part[:, column] ^= x_part[:, q]
770770

771771
# reduce stabilizers below row
772772
x_part[:, column] = 0
773773
x_part[row, column] = 1
774774

775-
circ.append("H", initialized) # ty: ignore[no-matching-overload]
775+
circ.append("H", initialized)
776776
circ = circ.inverse()
777777

778778
signs = [s.sign for s in circ.to_tableau().to_stabilizers()]

src/mqt/qecc/circuit_synthesis/noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def apply(self, circ: Circuit) -> Circuit:
244244
assert isinstance(op, CircuitInstruction)
245245
for grp in op.target_groups():
246246
layer_circ = Circuit()
247-
layer_circ.append(op.name, grp) # ty: ignore[no-matching-overload]
247+
layer_circ.append(op.name, grp)
248248
layers.append(layer_circ)
249249

250250
if self.resets_alap:

src/mqt/qecc/circuit_synthesis/operations.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,18 @@ def append_to_circuit(self, circuit: stim.Circuit) -> None:
187187
basis_change = {"Z": [], "X": ["H"], "Y": ["S_DAG", "H"]}
188188
undo_basis_change = {"Z": [], "X": ["H"], "Y": ["H", "S"]}
189189
for g in basis_change[p_i]:
190-
circuit.append(g, [i]) # ty: ignore[no-matching-overload]
190+
circuit.append(g, [i])
191191
for g in basis_change[p_j]:
192-
circuit.append(g, [j]) # ty: ignore[no-matching-overload]
192+
circuit.append(g, [j])
193193

194-
circuit.append("CZ", [i, j]) # ty: ignore[no-matching-overload]
195-
circuit.append("S", [i]) # ty: ignore[no-matching-overload]
196-
circuit.append("S", [j]) # ty: ignore[no-matching-overload]
194+
circuit.append("CZ", [i, j])
195+
circuit.append("S", [i])
196+
circuit.append("S", [j])
197197

198198
for g in undo_basis_change[p_j]:
199-
circuit.append(g, [j]) # ty: ignore[no-matching-overload]
199+
circuit.append(g, [j])
200200
for g in undo_basis_change[p_i]:
201-
circuit.append(g, [i]) # ty: ignore[no-matching-overload]
201+
circuit.append(g, [i])
202202

203203
def qubits(self) -> set[int]:
204204
"""Get the set of qubits involved in the operation.
@@ -395,29 +395,29 @@ def append_to_circuit(self, circuit: stim.Circuit) -> None:
395395
circuit: The Stim circuit to append the operation to.
396396
"""
397397
if self.clifford in {"H", "S", "I"}:
398-
circuit.append(self.clifford, [self.qubit]) # ty: ignore[no-matching-overload]
398+
circuit.append(self.clifford, [self.qubit])
399399
elif self.clifford == "SDAG":
400-
circuit.append("S_DAG", [self.qubit]) # ty: ignore[no-matching-overload]
400+
circuit.append("S_DAG", [self.qubit])
401401
elif self.clifford == "HS":
402-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
403-
circuit.append("S", [self.qubit]) # ty: ignore[no-matching-overload]
402+
circuit.append("H", [self.qubit])
403+
circuit.append("S", [self.qubit])
404404
elif self.clifford == "SH":
405-
circuit.append("S", [self.qubit]) # ty: ignore[no-matching-overload]
406-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
405+
circuit.append("S", [self.qubit])
406+
circuit.append("H", [self.qubit])
407407
elif self.clifford == "HSH":
408-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
409-
circuit.append("S", [self.qubit]) # ty: ignore[no-matching-overload]
410-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
408+
circuit.append("H", [self.qubit])
409+
circuit.append("S", [self.qubit])
410+
circuit.append("H", [self.qubit])
411411
elif self.clifford == "SDAGH":
412-
circuit.append("S_DAG", [self.qubit]) # ty: ignore[no-matching-overload]
413-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
412+
circuit.append("S_DAG", [self.qubit])
413+
circuit.append("H", [self.qubit])
414414
elif self.clifford == "HSDAG":
415-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
416-
circuit.append("S_DAG", [self.qubit]) # ty: ignore[no-matching-overload]
415+
circuit.append("H", [self.qubit])
416+
circuit.append("S_DAG", [self.qubit])
417417
elif self.clifford == "HSDAGH":
418-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
419-
circuit.append("S_DAG", [self.qubit]) # ty: ignore[no-matching-overload]
420-
circuit.append("H", [self.qubit]) # ty: ignore[no-matching-overload]
418+
circuit.append("H", [self.qubit])
419+
circuit.append("S_DAG", [self.qubit])
420+
circuit.append("H", [self.qubit])
421421
else:
422422
msg = f"Unsupported single-qubit Clifford operation: {self.clifford}"
423423
raise ValueError(msg)
@@ -501,7 +501,7 @@ def append_to_circuit(self, circuit: stim.Circuit) -> None:
501501
Args:
502502
circuit: The Stim circuit to append the operation to.
503503
"""
504-
circuit.append(self.pauli, [self.qubit]) # ty: ignore[no-matching-overload]
504+
circuit.append(self.pauli, [self.qubit])
505505

506506
def qubits(self) -> set[int]:
507507
"""Get the set of qubits involved in the operation.
@@ -574,7 +574,7 @@ def append_to_circuit(self, circuit: stim.Circuit) -> None:
574574
Args:
575575
circuit: The Stim circuit to append the operation to.
576576
"""
577-
circuit.append("CNOT", [self.control, self.target]) # ty: ignore[no-matching-overload]
577+
circuit.append("CNOT", [self.control, self.target])
578578

579579
def qubits(self) -> set[int]:
580580
"""Get the set of qubits involved in the operation.
@@ -644,7 +644,7 @@ def append_to_circuit(self, circuit: stim.Circuit) -> None:
644644
Args:
645645
circuit: The Stim circuit to append the operation to.
646646
"""
647-
circuit.append("SWAP", [self.qubit_a, self.qubit_b]) # ty: ignore[no-matching-overload]
647+
circuit.append("SWAP", [self.qubit_a, self.qubit_b])
648648

649649
def qubits(self) -> set[int]:
650650
"""Get the set of qubits involved in the operation.

0 commit comments

Comments
 (0)