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

refactor: minor improvement to qiskit_to_tk conversion. #404

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

CalMacCQ
Copy link
Contributor

@CalMacCQ CalMacCQ commented Oct 23, 2024

Description

Just pulled out the circbox building in qiskit_to_tk into a separate function. This reduces indentation and the number of lines in the CircuitBuilder.add_qiskit_data method.

Related issues

#313

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@CalMacCQ CalMacCQ requested a review from cqc-melf as a code owner October 23, 2024 14:58
@@ -524,7 +534,7 @@ def add_qiskit_data(
q_ctrl_box = _get_qcontrol_box(c_gate=instr, params=params)
self.tkc.add_qcontrolbox(q_ctrl_box, qubits)

elif isinstance(instr, (Initialize, StatePreparation)):
elif optype == OpType.StatePreparationBox:
Copy link
Contributor Author

@CalMacCQ CalMacCQ Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems more correct to match the optype as both of the qiskit instructions are mapped to a StatePreparationBox instance.

Copy link
Contributor Author

@CalMacCQ CalMacCQ Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact we could probably rewrite CircuitBuilder.add_qiskit_data to just check the optype and not look at the qiskit Instruction. This would be nicer as the whole method would just be matching on the values of the optype variable. Its just the handling of UnitaryGate and PauliEvolutionGate that are preventing this at the moment.

@CalMacCQ CalMacCQ merged commit 96d01b1 into main Oct 24, 2024
6 checks passed
@CalMacCQ CalMacCQ deleted the imporve/qiskit_to_tk branch October 24, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants