Skip to content

Commit

Permalink
Merge pull request #60 from CQCL/release/1.26.0
Browse files Browse the repository at this point in the history
Release/1.26.0
  • Loading branch information
cqc-melf authored Mar 19, 2024
2 parents aa7f252 + dd9c968 commit 94cd6b7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
- package-ecosystem: pip
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected].3
uses: actions/[email protected].4
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.31.0"
__extension_version__ = "0.32.0"
__extension_name__ = "pytket-pyzx"
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
~~~~~~~~~

0.32.0 (March 2024)
-------------------

* Updated pytket version requirement to 1.26.
* Updated pyzx version requirement to 0.8.0.

0.31.0 (January 2024)
---------------------

Expand Down
44 changes: 23 additions & 21 deletions pytket/extensions/pyzx/pyzx_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Methods to allow conversion between pyzx and tket data types
"""
"""Methods to allow conversion between pyzx and tket data types"""

from typing import Dict, Tuple
from fractions import Fraction
import pyzx as zx # type: ignore
from pyzx.circuit import Circuit as pyzxCircuit # type: ignore
from pyzx.routing.architecture import Architecture as PyzxArc # type: ignore
from pyzx.graph.graph import Graph as PyzxGraph # type: ignore
from pyzx.circuit import Circuit as pyzxCircuit, gates as zxGates
from pyzx.routing.architecture import Architecture as PyzxArc
from pyzx.graph.graph import Graph as PyzxGraph
from pytket.circuit import OpType, Circuit, Op, Qubit, UnitID
from pytket.architecture import Architecture

_tk_to_pyzx_gates = {
OpType.Rz: zx.gates.ZPhase,
OpType.Rx: zx.gates.XPhase,
OpType.X: zx.gates.NOT,
OpType.Z: zx.gates.Z,
OpType.S: zx.gates.S, # gate.adjoint == False
OpType.Sdg: zx.gates.S, # gate.adjoint == True
OpType.T: zx.gates.T, # gate.adjoint == False
OpType.Tdg: zx.gates.T, # gate.adjoint == True
OpType.CX: zx.gates.CNOT,
OpType.CZ: zx.gates.CZ,
OpType.H: zx.gates.HAD,
OpType.SWAP: zx.gates.SWAP,
OpType.Rz: zxGates.ZPhase,
OpType.Rx: zxGates.XPhase,
OpType.X: zxGates.NOT,
OpType.Z: zxGates.Z,
OpType.S: zxGates.S, # gate.adjoint == False
OpType.Sdg: zxGates.S, # gate.adjoint == True
OpType.T: zxGates.T, # gate.adjoint == False
OpType.Tdg: zxGates.T, # gate.adjoint == True
OpType.CX: zxGates.CNOT,
OpType.CZ: zxGates.CZ,
OpType.H: zxGates.HAD,
OpType.SWAP: zxGates.SWAP,
}

_pyzx_to_tk_gates: Dict = dict(
Expand Down Expand Up @@ -75,11 +73,11 @@ def tk_to_pyzx(tkcircuit: Circuit, denominator_limit: int = 1000000) -> pyzxCirc
gate_class = _tk_to_pyzx_gates[op.type]
adjoint = op.type == OpType.Sdg or op.type == OpType.Tdg
qbs = [q.index[0] for q in command.args]
gate = 0 # assignment
gate: zxGates.Gate # assignment
n_params = len(op.params)
if n_params == 1:
phase = op.params[0]
if type(phase) != float:
if not isinstance(phase, float):
raise Exception(
"Cannot convert tket gate: "
+ str(op)
Expand Down Expand Up @@ -127,7 +125,11 @@ def pyzx_to_tk(pyzx_circ: pyzxCircuit) -> Circuit:
elif op_type == OpType.Tdg and not getattr(g, "adjoint"):
op_type = OpType.T

if hasattr(g, "printphase") and op_type in _parameterised_gates:
if (
hasattr(g, "print_phase")
and hasattr(g, "phase")
and op_type in _parameterised_gates
):
op = Op.create(op_type, g.phase)
else:
op = Op.create(op_type)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
license="Apache 2",
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=["pytket ~= 1.24", "pyzx ~= 0.7.0"],
install_requires=["pytket ~= 1.26", "pyzx ~= 0.8.0"],
classifiers=[
"Environment :: Console",
"Programming Language :: Python :: 3.10",
Expand Down
2 changes: 1 addition & 1 deletion tests/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest
pytest-timeout ~= 2.2.0
pytest-timeout ~= 2.3.1
hypothesis
requests_mock

0 comments on commit 94cd6b7

Please sign in to comment.