Skip to content

Commit

Permalink
Fix FlattenRelabelRegistersPass (#1441)
Browse files Browse the repository at this point in the history
* update tket version

* update parameter of remove_blank_wires in gen_flatten_relabel_registers_pass

* add python testcase for compilation pass flatten_relabel

* update tket version
  • Loading branch information
cqc-melf authored Jun 7, 2024
1 parent ef2909d commit 5139818
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
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.3.5@tket/stable")
self.requires("tket/1.3.6@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
10 changes: 9 additions & 1 deletion pytket/tests/predicates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Unitary2qBox,
Node,
Qubit,
Bit,
UnitID,
Conditional,
)
Expand Down Expand Up @@ -885,7 +886,10 @@ def test_conditional_phase() -> None:


def test_flatten_relabel_pass() -> None:
c = Circuit(3)
c = Circuit(3, 3)
c.add_bit(Bit("d", 0))
c.add_bit(Bit("d", 1))
c.add_c_register("e", 5)
c.H(1).H(2)
rename_map: RenameUnitsMap = dict()
rename_map[Qubit(0)] = Qubit("a", 4)
Expand All @@ -901,6 +905,10 @@ def test_flatten_relabel_pass() -> None:
assert cu.initial_map[Qubit("a", 4)] == Qubit("a", 4)
assert cu.initial_map[Qubit("b", 7)] == Qubit("a", 1)
assert cu.circuit.qubits == [Qubit("a", 0), Qubit("a", 1)]
assert cu.circuit.n_bits == 10
assert cu.circuit.get_c_register("c").size == 3
assert cu.circuit.get_c_register("d").size == 2
assert cu.circuit.get_c_register("e").size == 5

# test default argument
c = Circuit()
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.3.5"
version = "1.3.6"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
2 changes: 1 addition & 1 deletion tket/src/Predicates/PassGenerators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ PassPtr gen_flatten_relabel_registers_pass(const std::string& label) {
Transform t =
Transform([=](Circuit& circuit, std::shared_ptr<unit_bimaps_t> maps) {
unsigned n_qubits = circuit.n_qubits();
circuit.remove_blank_wires(false);
circuit.remove_blank_wires(true);
bool changed = circuit.n_qubits() < n_qubits;
std::map<Qubit, Qubit> relabelling_map;
std::vector<Qubit> all_qubits = circuit.all_qubits();
Expand Down

0 comments on commit 5139818

Please sign in to comment.