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

add testcase for symbolic conversion #315

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
24 changes: 24 additions & 0 deletions tests/qiskit_convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
from qiskit.circuit.equivalence_library import StandardEquivalenceLibrary # type: ignore
from qiskit_ibm_runtime.fake_provider import FakeGuadalupe # type: ignore
from qiskit.circuit.parameterexpression import ParameterExpression # type: ignore
from pytket.extensions.qiskit import qiskit_to_tk, tk_to_qiskit
from qiskit.circuit.library import TwoLocal
from qiskit import transpile

from pytket.circuit import (
Circuit,
Expand Down Expand Up @@ -1091,3 +1094,24 @@ def test_RealAmplitudes_numeric_params() -> None:
unitary2 = tkc2.get_unitary()
assert compare_unitaries(qiskit_unitary, unitary1)
assert compare_unitaries(unitary1, unitary2)


# https://github.com/CQCL/pytket-qiskit/issues/256
def test_symbolic_param_conv() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I note that this test does not have an assert statement or anything of that kind.

Is the idea just to ensure that this code executes successfully and doesn't give the

TypeError: EvalfMixin.evalf() got an unexpected keyword argument 'real'

As before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that was my idea, I was thinking about checking stuff in the final circuit, but I would expect the way qiskit is setting up the circuit or the compilation works might change without generating any issues here, so I decided not to do any additional checks.

qc = TwoLocal(1, "ry", "cz", reps=1, entanglement="linear")
qc_transpiled = transpile(
qc, basis_gates=["sx", "rz", "cx", "x"], optimization_level=3
)

tket_qc = qiskit_to_tk(qc_transpiled)
CliffordSimp().apply(tket_qc)
transformed_qc = tk_to_qiskit(tket_qc)

qc_transpiled_again = transpile(transformed_qc, basis_gates=["sx", "rz", "cx", "x"])

qc_transpiled_again = qc_transpiled_again.assign_parameters(
{
qc_transpiled_again.parameters[i]: 0
for i in range(len(qc_transpiled_again.parameters))
}
)