Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/actions/upload-…
Browse files Browse the repository at this point in the history
…artifact-4
  • Loading branch information
cqc-melf authored Dec 20, 2023
2 parents d9cc935 + a031a2f commit 5615d24
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
20 changes: 20 additions & 0 deletions pytket/binders/circuit/Circuit/add_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,16 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
"(Z) basis."
"\n\n:return: the new :py:class:`Circuit`",
py::arg("qubit"), py::arg("bit_index"))
.def(
"Reset",
[](Circuit *circ, unsigned qb, const py::kwargs &kwargs) {
return add_gate_method_noparams<unsigned>(
circ, OpType::Reset, {qb}, kwargs);
},
"Appends a Reset operation. Sets a qubit to the Z-basis 0 state. "
"Non-unitary operation."
"\n\n:return: the new :py:class:`Circuit`",
py::arg("qubit"))
.def(
"Rz",
[](Circuit *circ, const Expr &angle, unsigned qb,
Expand Down Expand Up @@ -1680,6 +1690,16 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
"(Z) basis."
"\n\n:return: the new :py:class:`Circuit`",
py::arg("qubit"), py::arg("bit"))
.def(
"Reset",
[](Circuit *circ, const Qubit &qb, const py::kwargs &kwargs) {
return add_gate_method_noparams<UnitID>(
circ, OpType::Reset, {qb}, kwargs);
},
"Appends a Reset operation. Sets a qubit to the Z-basis 0 state. "
"Non-unitary operation."
"\n\n:return: the new :py:class:`Circuit`",
py::arg("qubit"))
.def(
"Rz",
[](Circuit *circ, const Expr &angle, const Qubit &qb,
Expand Down
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.2.75@tket/stable")
self.requires("tket/1.2.77@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.4@tket/stable")
Expand Down
14 changes: 14 additions & 0 deletions pytket/pytket/_tket/circuit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,20 @@ class Circuit:
:return: the new :py:class:`Circuit`
"""
@typing.overload
def Reset(self, qubit: int, **kwargs: Any) -> Circuit:
"""
Appends a Reset operation. Sets a qubit to the Z-basis 0 state. Non-unitary operation.
:return: the new :py:class:`Circuit`
"""
@typing.overload
def Reset(self, qubit: pytket._tket.unit_id.Qubit, **kwargs: Any) -> Circuit:
"""
Appends a Reset operation. Sets a qubit to the Z-basis 0 state. Non-unitary operation.
:return: the new :py:class:`Circuit`
"""
@typing.overload
def Rx(self, angle: sympy.Expr | float, qubit: int, **kwargs: Any) -> Circuit:
"""
Appends an Rx gate with a possibly symbolic angle (specified in half-turns).
Expand Down
10 changes: 6 additions & 4 deletions pytket/tests/add_circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@
import pytest


def gen_bell_state() -> Circuit:
def gen_bell_state(reset_start: bool = False) -> Circuit:
circ = Circuit(2)
if reset_start:
circ = circ.Reset(0).Reset(1)
circ.H(0)
circ.CX(0, 1)
return circ


def test_direct_add() -> None:
a = gen_bell_state()
a = gen_bell_state(True)
b = Circuit(1)
b.add_gate(OpType.X, [0])
a.add_circuit(b, [0])
assert a.n_gates == 3
assert a.n_gates == 5
assert a.n_qubits == 2
assert a.depth() == 3
assert a.depth() == 4


def test_swap_add() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.2.75"
version = "1.2.77"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down

0 comments on commit 5615d24

Please sign in to comment.