From 05c495ff694b9db21d718cb51cbcfc15da474b2f Mon Sep 17 00:00:00 2001 From: Luca Mondada Date: Wed, 4 Oct 2023 14:20:47 +0200 Subject: [PATCH] Add comments --- tests/taso_termination.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/taso_termination.rs b/tests/taso_termination.rs index a61534e5..78ae87ac 100644 --- a/tests/taso_termination.rs +++ b/tests/taso_termination.rs @@ -9,24 +9,40 @@ mod require_portmatching { }; use tket_json_rs::circuit_json::SerialCircuit; + /// A set of equivalence circuit classes (ECC) + /// + /// This is the complete set of ECCs for 2-qubit circuits with up to + /// 4 gates, using the NAM gateset (CX, Rz, H). #[fixture] fn nam_4_2() -> DefaultTasoOptimiser { - // TasoOptimiser::default_with_rewriter_binary("test_files/nam_4_2.rwr").unwrap() TasoOptimiser::default_with_eccs_json_file("test_files/Nam_4_2_complete_ECC_set.json") .unwrap() } + /// The following circuit + /// ┌──────────┐ ┌───────────┐ + ///q_0: ──■──┤ Rz(π/10) ├──■─────────────────────────■────■──┤ Rz(-π/10) ├ + /// │ └──────────┘┌─┴─┐┌───┐┌─────────┐┌───┐┌─┴─┐ │ └───────────┘ + ///q_1: ──┼──────────────┤ X ├┤ H ├┤ Rz(π/5) ├┤ H ├┤ X ├──┼─────────────── + /// ┌─┴─┐ └───┘└───┘└─────────┘└───┘└───┘┌─┴─┐ + ///q_2: ┤ X ├───────────────────────────────────────────┤ X ├───────────── + /// └───┘ └───┘ #[fixture] fn simple_circ() -> Hugr { - let json = r#" - {"bits": [], "commands": [{"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"params": ["0.1"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"params": ["0.2"], "type": "Rz"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"params": ["-0.1"], "type": "Rz"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]} - "#; + // The TK1 json of the circuit + let json = r#"{ + "bits": [], + "commands": [{"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"params": ["0.1"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"params": ["0.2"], "type": "Rz"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"params": ["-0.1"], "type": "Rz"}}], + "created_qubits": [], + "discarded_qubits": [], + "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]] + }"#; let ser: SerialCircuit = serde_json::from_str(json).unwrap(); ser.decode().unwrap() } #[rstest] - #[ignore = "Takes 800ms"] + // #[ignore = "Takes 800ms"] fn taso_termination(simple_circ: Hugr, nam_4_2: DefaultTasoOptimiser) { let opt_circ = nam_4_2.optimise(&simple_circ, None, 1.try_into().unwrap()); assert_eq!(opt_circ.commands().count(), 11);