Skip to content

Commit

Permalink
update conversion to use symengine (#314)
Browse files Browse the repository at this point in the history
* update conversion to use symengine

* update version and changelog

* fix mypy
  • Loading branch information
cqc-melf authored Apr 5, 2024
1 parent e47cd6b commit d4cf77d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.51.0"
__extension_version__ = "0.51.1rc0"
__extension_name__ = "pytket-qiskit"
5 changes: 3 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Changelog
~~~~~~~~~

Unreleased
----------
0.51.1rc0 (April 2024)
----------------------

* Update pytket version requirement to 1.26.
* Update qiskit-aer version requirement to 0.14.
* Update conversion to qiskit to use symengine for symbolic circuits

0.51.0 (March 2024)
-------------------
Expand Down
7 changes: 4 additions & 3 deletions pytket/extensions/qiskit/qiskit_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from uuid import UUID

import numpy as np
from symengine import sympify # type: ignore

import sympy
import qiskit.circuit.library.standard_gates as qiskit_gates # type: ignore
Expand Down Expand Up @@ -580,7 +581,7 @@ def param_to_qiskit(
if len(ppi.free_symbols) == 0:
return float(ppi.evalf())
else:
return ParameterExpression(symb_map, ppi)
return ParameterExpression(symb_map, sympify(ppi))


def _get_params(
Expand Down Expand Up @@ -724,7 +725,7 @@ def append_tk_command_to_qiskit(

if optype == OpType.TK1:
params = _get_params(op, symb_map)
half = ParameterExpression(symb_map, sympy.pi / 2)
half = ParameterExpression(symb_map, sympify(sympy.pi / 2))
qcirc.global_phase += -params[0] / 2 - params[2] / 2
return qcirc.append(
qiskit_gates.UGate(params[1], params[0] - half, params[2] + half),
Expand All @@ -749,7 +750,7 @@ def append_tk_command_to_qiskit(
if type(phase) == float:
qcirc.global_phase += phase * np.pi
else:
qcirc.global_phase += phase * sympy.pi
qcirc.global_phase += sympify(phase * sympy.pi)
return qcirc.append(g, qargs=qargs)


Expand Down

0 comments on commit d4cf77d

Please sign in to comment.