From d563c78981eceedc68c85f328fff8b80fa13e8e1 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Jaskula Date: Wed, 27 Dec 2023 10:50:24 -0500 Subject: [PATCH] code coverage --- src/braket/circuits/ascii_circuit_diagram.py | 12 ------ .../circuits/test_ascii_circuit_diagram.py | 38 ++++++++++++------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/braket/circuits/ascii_circuit_diagram.py b/src/braket/circuits/ascii_circuit_diagram.py index fdfc7a7d4..07928ec93 100644 --- a/src/braket/circuits/ascii_circuit_diagram.py +++ b/src/braket/circuits/ascii_circuit_diagram.py @@ -267,17 +267,6 @@ def _ascii_diagram_column_set( for i, moment_line in enumerate(column_str.split("\n")): lines[i] += moment_line - # Adjust for column title width - col_title_width = len(col_title) - symbols_width = len(lines[0]) - 1 - if symbols_width < col_title_width: - diff = col_title_width - symbols_width - for i in range(len(lines) - 1): - if lines[i].endswith("─"): - lines[i] += "─" * diff - else: - lines[i] += " " - first_line = "{:^{width}}│\n".format(col_title, width=len(lines[0]) - 1) return first_line + "\n".join(lines) @@ -384,7 +373,6 @@ def _ascii_diagram_column( connections[qubit] = "below" elif min(target_and_control) < qubit: connections[qubit] = "above" - continue elif qubit in control_qubits: symbols[qubit] = "●" if map_control_qubit_states[qubit] else "◯" diff --git a/test/unit_tests/braket/circuits/test_ascii_circuit_diagram.py b/test/unit_tests/braket/circuits/test_ascii_circuit_diagram.py index 8d3d97161..15693d3c0 100644 --- a/test/unit_tests/braket/circuits/test_ascii_circuit_diagram.py +++ b/test/unit_tests/braket/circuits/test_ascii_circuit_diagram.py @@ -229,18 +229,18 @@ def test_time_width(): def test_connector_across_two_qubits(): - circ = Circuit().cnot(3, 4).h(range(2, 6)) + circ = Circuit().cnot(4, 3).h(range(2, 6)) expected = ( "T : │ 0 │ 1 │", " ┌───┐ ", "q2 : ─┤ H ├───────", " └───┘ ", - " ┌───┐ ", - "q3 : ───●───┤ H ├─", - " │ └───┘ ", - " ┌─┴─┐ ┌───┐ ", - "q4 : ─┤ X ├─┤ H ├─", - " └───┘ └───┘ ", + " ┌───┐ ┌───┐ ", + "q3 : ─┤ X ├─┤ H ├─", + " └─┬─┘ └───┘ ", + " │ ┌───┐ ", + "q4 : ───●───┤ H ├─", + " └───┘ ", " ┌───┐ ", "q5 : ─┤ H ├───────", " └───┘ ", @@ -250,18 +250,18 @@ def test_connector_across_two_qubits(): def test_neg_control_qubits(): - circ = Circuit().x(2, control=[0, 1], control_state=[0, 1]) + circ = Circuit().x(1, control=[0, 2], control_state=[0, 1]) expected = ( "T : │ 0 │", " ", "q0 : ───◯───", " │ ", - " │ ", - "q1 : ───●───", - " │ ", " ┌─┴─┐ ", - "q2 : ─┤ X ├─", - " └───┘ ", + "q1 : ─┤ X ├─", + " └─┬─┘ ", + " │ ", + "q2 : ───●───", + " ", "T : │ 0 │", ) _assert_correct_diagram(circ, expected) @@ -593,6 +593,18 @@ def to_ir(self, target): _assert_correct_diagram(circ, expected) +def test_single_qubit_result_types_target_none(): + circ = Circuit().h(0).probability() + expected = ( + "T : │ 0 │ Result Types │", + " ┌───┐ ┌─────────────┐ ", + "q0 : ─┤ H ├─┤ Probability ├─", + " └───┘ └─────────────┘ ", + "T : │ 0 │ Result Types │", + ) + _assert_correct_diagram(circ, expected) + + def test_result_types_target_none(): circ = Circuit().h(0).h(100).probability() expected = (