diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f384d36..0d8ea0b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" + interval: "weekly" - package-ecosystem: pip directory: "/" schedule: diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 45abd85..634d9f0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -154,4 +154,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4.0.3 + uses: actions/deploy-pages@v4.0.4 diff --git a/_metadata.py b/_metadata.py index 9f68209..4dbfc8e 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.31.0" +__extension_version__ = "0.32.0" __extension_name__ = "pytket-pyzx" diff --git a/docs/changelog.rst b/docs/changelog.rst index 18b811f..801c4a8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) --------------------- diff --git a/pytket/extensions/pyzx/pyzx_convert.py b/pytket/extensions/pyzx/pyzx_convert.py index c5e516d..5d50cda 100644 --- a/pytket/extensions/pyzx/pyzx_convert.py +++ b/pytket/extensions/pyzx/pyzx_convert.py @@ -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( @@ -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) @@ -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) diff --git a/setup.py b/setup.py index 78659ac..0f0a188 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tests/test-requirements.txt b/tests/test-requirements.txt index 7103107..3e2e603 100644 --- a/tests/test-requirements.txt +++ b/tests/test-requirements.txt @@ -1,4 +1,4 @@ pytest -pytest-timeout ~= 2.2.0 +pytest-timeout ~= 2.3.1 hypothesis requests_mock