Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded "type: ignore" comments. #188

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pytket/extensions/qiskit/backends/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_ibmq_config(

config = QiskitConfig.from_default_config_file()
if instance is not None:
config.instance = instance # type: ignore
config.instance = instance
if ibmq_api_token is not None:
config.ibmq_api_token = ibmq_api_token # type: ignore
config.ibmq_api_token = ibmq_api_token
config.update_default_config_file()
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(
super().__init__()
self._pytket_config = QiskitConfig.from_default_config_file()
self._provider = (
self._get_provider(instance=instance, qiskit_config=self._pytket_config) # type: ignore
self._get_provider(instance=instance, qiskit_config=self._pytket_config)
if provider is None
else provider
)
Expand Down
12 changes: 6 additions & 6 deletions pytket/extensions/qiskit/qiskit_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
sub_circ = Circuit(n_base_qubits)
# use base gate name for the CircBox (shows in renderer)
sub_circ.name = instr.base_gate.name.capitalize()
sub_circ.add_gate(base_tket_gate, params, list(range(n_base_qubits))) # type: ignore
sub_circ.add_gate(base_tket_gate, params, list(range(n_base_qubits)))
c_box = CircBox(sub_circ)
q_ctrl_box = QControlBox(c_box, instr.num_ctrl_qubits)
self.tkc.add_qcontrolbox(q_ctrl_box, qubits) # type: ignore
self.tkc.add_qcontrolbox(q_ctrl_box, qubits)

elif isinstance(instr, (Initialize, StatePreparation)):
# Check how Initialize or StatePrep is constructed
Expand All @@ -421,7 +421,7 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
)
# Need to reverse qubits here (endian-ness)
reversed_qubits = list(reversed(qubits))
self.tkc.add_gate(pytket_state_prep_box, reversed_qubits) # type: ignore
self.tkc.add_gate(pytket_state_prep_box, reversed_qubits)

elif isinstance(instr.params[0], complex) and len(instr.params) == 1:
# convert int to a binary string and apply X for |1>
Expand All @@ -437,7 +437,7 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
empty_circ = Circuit(len(qargs))
circ = gen_term_sequence_circuit(qpo, empty_circ)
ccbox = CircBox(circ)
self.tkc.add_circbox(ccbox, qubits) # type: ignore
self.tkc.add_circbox(ccbox, qubits)
elif type(instr) == UnitaryGate:
# Note reversal of qubits, to account for endianness (pytket unitaries
# are ILO-BE == DLO-LE; qiskit unitaries are ILO-LE == DLO-BE).
Expand Down Expand Up @@ -471,7 +471,7 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
)

elif optype == OpType.Barrier:
self.tkc.add_barrier(qubits) # type: ignore
self.tkc.add_barrier(qubits)
elif optype in (OpType.CircBox, OpType.CustomGate):
qregs = (
[QuantumRegister(instr.num_qubits, "q")]
Expand Down Expand Up @@ -502,7 +502,7 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
self.tkc.add_gate(
optype,
[param_to_tk(p) for p in instr.params[:-1]],
qubits, # type: ignore
qubits,
**condition_kwargs,
)
else:
Expand Down
12 changes: 6 additions & 6 deletions tests/qiskit_convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,15 @@ def test_parameter_equality() -> None:
# https://github.com/CQCL/pytket-extensions/issues/275
def test_convert_multi_c_reg() -> None:
c = Circuit()
q0, q1 = c.add_q_register("q", 2) # type: ignore
q0, q1 = c.add_q_register("q", 2)
c.add_c_register("c", 2)
[m0] = c.add_c_register("m", 1) # type: ignore
c.add_gate(OpType.X, [], [q1], condition_bits=[m0], condition_value=1) # type: ignore
c.CX(q0, q1) # type: ignore
c.add_gate(OpType.TK1, [0.5, 0.5, 0.5], [q0]) # type: ignore
[m0] = c.add_c_register("m", 1)
c.add_gate(OpType.X, [], [q1], condition_bits=[m0], condition_value=1)
c.CX(q0, q1)
c.add_gate(OpType.TK1, [0.5, 0.5, 0.5], [q0])
qcirc = tk_to_qiskit(c)
circ = qiskit_to_tk(qcirc)
assert circ.get_commands()[0].args == [m0, q1] # type: ignore
assert circ.get_commands()[0].args == [m0, q1]


# test that tk_to_qiskit works after adding OpType.CRx and OpType.CRy
Expand Down