diff --git a/qiskit/circuit/tools/pi_check.py b/qiskit/circuit/tools/pi_check.py index b1ee360fea42..67efe26c3ebc 100644 --- a/qiskit/circuit/tools/pi_check.py +++ b/qiskit/circuit/tools/pi_check.py @@ -67,7 +67,9 @@ def normalize(single_inpt): if abs(single_inpt) < 1e-14: return '0' - if output in ['text', 'qasm']: + if output == 'text': + pi = 'π' + elif output == 'qasm': pi = 'pi' elif output == 'latex': pi = '\\pi' diff --git a/test/python/circuit/test_tools.py b/test/python/circuit/test_tools.py index 8c7489b36a37..bde3bfbf1629 100644 --- a/test/python/circuit/test_tools.py +++ b/test/python/circuit/test_tools.py @@ -26,42 +26,42 @@ class TestPiCheck(QiskitTestCase): """ qiskit/visualization/tools/pi_check.py """ @combine(case=[(3.14, '3.14'), - (3.141592653589793, 'pi'), - (6.283185307179586, '2pi'), + (3.141592653589793, 'π'), + (6.283185307179586, '2π'), (2.99, '2.99'), (2.999999999999999, '3'), (0.99, '0.99'), (0.999999999999999, '1'), - (pi, 'pi'), - (-pi, '-pi'), - (3*pi, '3pi'), - (-3*pi, '-3pi'), - (pi/35, 'pi/35'), - (-pi/35, '-pi/35'), + (pi, 'π'), + (-pi, '-π'), + (3*pi, '3π'), + (-3*pi, '-3π'), + (pi/35, 'π/35'), + (-pi/35, '-π/35'), (3*pi/35, '0.26928'), (-3*pi/35, '-0.26928'), - (pi**2, 'pi**2'), - (-pi**2, '-pi**2'), + (pi**2, 'π**2'), + (-pi**2, '-π**2'), (1e9, '1e+09'), (-1e9, '-1e+09'), (1e-9, '1e-09'), (-1e-9, '-1e-09'), - (6*pi/11, '6pi/11'), - (-6*pi/11, '-6pi/11'), - (6*pi/1, '6pi'), - (-6*pi/1, '-6pi'), - (6*pi/2, '3pi'), - (-6*pi/2, '-3pi'), - (1j*3/(7*pi), '3/7pij'), - (-1j*3/(7*pi), '-3/7pij'), - (6*pi/5+1j*3*pi/7, '6pi/5+3pi/7j'), - (-6*pi/5+1j*3*pi/7, '-6pi/5+3pi/7j'), - (6*pi/5-1j*3*pi/7, '6pi/5-3pi/7j'), - (-6*pi/5-1j*3*pi/7, '-6pi/5-3pi/7j'), - (1/pi, '1/pi'), - (-1/pi, '-1/pi'), - (6/(5*pi), '6/5pi'), - (-6/(5*pi), '-6/5pi'), + (6*pi/11, '6π/11'), + (-6*pi/11, '-6π/11'), + (6*pi/1, '6π'), + (-6*pi/1, '-6π'), + (6*pi/2, '3π'), + (-6*pi/2, '-3π'), + (1j*3/(7*pi), '3/7πj'), + (-1j*3/(7*pi), '-3/7πj'), + (6*pi/5+1j*3*pi/7, '6π/5+3π/7j'), + (-6*pi/5+1j*3*pi/7, '-6π/5+3π/7j'), + (6*pi/5-1j*3*pi/7, '6π/5-3π/7j'), + (-6*pi/5-1j*3*pi/7, '-6π/5-3π/7j'), + (1/pi, '1/π'), + (-1/pi, '-1/π'), + (6/(5*pi), '6/5π'), + (-6/(5*pi), '-6/5π'), (-382578.0+.0234567j, '-3.8258e+05+0.023457j'), (-382578.0-.0234567j, '-3.8258e+05-0.023457j') ]) @@ -77,7 +77,7 @@ def test_params(self): x = Parameter('x') y = Parameter('y') z = Parameter('z') - pcase = (pi**3 * x + 3/(4*pi) * y - 13*pi/2 * z, 'pi**3*x + 3/4pi*y - 13pi/2*z') + pcase = (pi**3 * x + 3/(4*pi) * y - 13*pi/2 * z, 'π**3*x + 3/4π*y - 13π/2*z') input_number = pcase[0] expected_string = pcase[1] result = pi_check(input_number) diff --git a/test/python/visualization/references/circuit_text_ref_cp437.txt b/test/python/visualization/references/circuit_text_ref_cp437.txt index f8cbcdfe20ec..8ab9848cca55 100644 --- a/test/python/visualization/references/circuit_text_ref_cp437.txt +++ b/test/python/visualization/references/circuit_text_ref_cp437.txt @@ -1,13 +1,13 @@ - ĿĿĿ ĿĿĿĿĿĿĿĿ ĿĿĿĿĿĿ Ŀ -q_0: |0> X ô Y ô Z İĴ H ô S ô SDG ô T ô TDG ô X ô XDG ô I |0>Ĵ RX(pi) ô RY(pi) ô RZ(pi) ô U1(pi) ô U2(pi,pi) ô U3(pi,pi,pi) XĴM - İ ĿĿ Ŀ pi ĿĿĿĿ Ŀ -q_1: |0>İXĴ X ô Y Ĵ H Ĵ U3(pi,pi,pi) ô RZ(pi) ô RY(pi) ô RX(pi) XĴM - Ŀ Ŀ -q_2: |0>İĴ X XĴM - - c_0: 0 - - c_1: 0 - - c_2: 0 - \ No newline at end of file + ĿĿĿ ĿĿĿĿĿĿĿĿ ĿĿĿĿĿĿ Ŀ +q_0: |0> X ô Y ô Z İĴ H ô S ô SDG ô T ô TDG ô X ô XDG ô I |0>Ĵ RX() ô RY() ô RZ() ô U1() ô U2(,) ô U3(,,) XĴM + İ ĿĿ Ŀ ĿĿĿĿ Ŀ +q_1: |0>İXĴ X ô Y Ĵ H Ĵ U3(,,) ô RZ() ô RY() ô RX() XĴM + Ŀ Ŀ +q_2: |0>İĴ X XĴM + + c_0: 0 + + c_1: 0 + + c_2: 0 + \ No newline at end of file diff --git a/test/python/visualization/references/circuit_text_ref_utf8.txt b/test/python/visualization/references/circuit_text_ref_utf8.txt index 14d0b0fa0e68..155709fc7011 100644 --- a/test/python/visualization/references/circuit_text_ref_utf8.txt +++ b/test/python/visualization/references/circuit_text_ref_utf8.txt @@ -1,13 +1,13 @@ - ┌───┐┌───┐┌───┐ ░ ┌───┐┌───┐┌─────┐┌───┐┌─────┐┌────┐┌──────┐┌───┐ ┌────────┐┌────────┐┌────────┐┌────────┐┌───────────┐┌──────────────┐ ┌─┐ -q_0: |0>┤ X ├┤ Y ├┤ Z ├─░─┤ H ├┤ S ├┤ SDG ├┤ T ├┤ TDG ├┤ √X ├┤ √XDG ├┤ I ├─|0>─┤ RX(pi) ├┤ RY(pi) ├┤ RZ(pi) ├┤ U1(pi) ├┤ U2(pi,pi) ├┤ U3(pi,pi,pi) ├─X───■────■───■───■───■──────────■────────────■─────────■─────────■───────■───■─┤M├────── - └─░─┘└───┘└───┘ ░ └───┘└───┘└─────┘└───┘└─────┘└────┘└──────┘└───┘ └────────┘└────────┘└────────┘└────────┘└───────────┘└──────────────┘ │ ┌─┴─┐┌─┴─┐ │ ┌─┴─┐ │pi ┌──────┴───────┐┌───┴────┐┌───┴────┐┌───┴────┐ │ │ └╥┘┌─┐ -q_1: |0>──░──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────X─┤ X ├┤ Y ├─■─┤ H ├─■───┤ U3(pi,pi,pi) ├┤ RZ(pi) ├┤ RY(pi) ├┤ RX(pi) ├──■───X──╫─┤M├─── - ░ └───┘└───┘ └───┘ └──────────────┘└────────┘└────────┘└────────┘┌─┴─┐ │ ║ └╥┘┌─┐ -q_2: |0>──░─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ X ├─X──╫──╫─┤M├ - ░ └───┘ ║ ║ └╥┘ - c_0: 0 ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬══╬═ - ║ ║ - c_1: 0 ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬═ - ║ - c_2: 0 ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩═ - \ No newline at end of file + ┌───┐┌───┐┌───┐ ░ ┌───┐┌───┐┌─────┐┌───┐┌─────┐┌────┐┌──────┐┌───┐ ┌───────┐┌───────┐┌───────┐┌───────┐┌─────────┐┌───────────┐ ┌─┐ +q_0: |0>┤ X ├┤ Y ├┤ Z ├─░─┤ H ├┤ S ├┤ SDG ├┤ T ├┤ TDG ├┤ √X ├┤ √XDG ├┤ I ├─|0>─┤ RX(π) ├┤ RY(π) ├┤ RZ(π) ├┤ U1(π) ├┤ U2(π,π) ├┤ U3(π,π,π) ├─X───■────■───■───■───■────────■──────────■────────■────────■──────■───■─┤M├────── + └─░─┘└───┘└───┘ ░ └───┘└───┘└─────┘└───┘└─────┘└────┘└──────┘└───┘ └───────┘└───────┘└───────┘└───────┘└─────────┘└───────────┘ │ ┌─┴─┐┌─┴─┐ │ ┌─┴─┐ │π ┌─────┴─────┐┌───┴───┐┌───┴───┐┌───┴───┐ │ │ └╥┘┌─┐ +q_1: |0>──░─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────X─┤ X ├┤ Y ├─■─┤ H ├─■──┤ U3(π,π,π) ├┤ RZ(π) ├┤ RY(π) ├┤ RX(π) ├──■───X──╫─┤M├─── + ░ └───┘└───┘ └───┘ └───────────┘└───────┘└───────┘└───────┘┌─┴─┐ │ ║ └╥┘┌─┐ +q_2: |0>──░─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ X ├─X──╫──╫─┤M├ + ░ └───┘ ║ ║ └╥┘ + c_0: 0 ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬══╬═ + ║ ║ + c_1: 0 ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬═ + ║ + c_2: 0 ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩═ + \ No newline at end of file diff --git a/test/python/visualization/test_circuit_text_drawer.py b/test/python/visualization/test_circuit_text_drawer.py index aa7f82969ed0..3a4b3f239c72 100644 --- a/test/python/visualization/test_circuit_text_drawer.py +++ b/test/python/visualization/test_circuit_text_drawer.py @@ -340,13 +340,13 @@ def test_text_cswap_reverse_bits(self): def test_text_cu3(self): """ cu3 drawing. """ - expected = '\n'.join([" ┌────────────────────┐", - "q_0: |0>──────────■───────────┤ U3(pi/2,pi/2,pi/2) ├", - " ┌─────────┴──────────┐└─────────┬──────────┘", - "q_1: |0>┤ U3(pi/2,pi/2,pi/2) ├──────────┼───────────", - " └────────────────────┘ │ ", - "q_2: |0>────────────────────────────────■───────────", - " "]) + expected = '\n'.join([" ┌─────────────────┐", + "q_0: |0>─────────■─────────┤ U3(π/2,π/2,π/2) ├", + " ┌────────┴────────┐└────────┬────────┘", + "q_1: |0>┤ U3(π/2,π/2,π/2) ├─────────┼─────────", + " └─────────────────┘ │ ", + "q_2: |0>────────────────────────────■─────────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) @@ -356,13 +356,13 @@ def test_text_cu3(self): def test_text_cu3_reverse_bits(self): """ cu3 drawing with reverse_bits""" - expected = '\n'.join([" ", - "q_2: |0>────────────────────────────────■───────────", - " ┌────────────────────┐ │ ", - "q_1: |0>┤ U3(pi/2,pi/2,pi/2) ├──────────┼───────────", - " └─────────┬──────────┘┌─────────┴──────────┐", - "q_0: |0>──────────■───────────┤ U3(pi/2,pi/2,pi/2) ├", - " └────────────────────┘"]) + expected = '\n'.join([" ", + "q_2: |0>────────────────────────────■─────────", + " ┌─────────────────┐ │ ", + "q_1: |0>┤ U3(π/2,π/2,π/2) ├─────────┼─────────", + " └────────┬────────┘┌────────┴────────┐", + "q_0: |0>─────────■─────────┤ U3(π/2,π/2,π/2) ├", + " └─────────────────┘"]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) @@ -372,13 +372,13 @@ def test_text_cu3_reverse_bits(self): def test_text_crz(self): """ crz drawing. """ - expected = '\n'.join([" ┌──────────┐", - "q_0: |0>─────■──────┤ RZ(pi/2) ├", - " ┌────┴─────┐└────┬─────┘", - "q_1: |0>┤ RZ(pi/2) ├─────┼──────", - " └──────────┘ │ ", - "q_2: |0>─────────────────■──────", - " "]) + expected = '\n'.join([" ┌─────────┐", + "q_0: |0>─────■─────┤ RZ(π/2) ├", + " ┌────┴────┐└────┬────┘", + "q_1: |0>┤ RZ(π/2) ├─────┼─────", + " └─────────┘ │ ", + "q_2: |0>────────────────■─────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.crz(pi / 2, qr[0], qr[1]) @@ -387,13 +387,13 @@ def test_text_crz(self): def test_text_cry(self): """ cry drawing. """ - expected = '\n'.join([" ┌──────────┐", - "q_0: |0>─────■──────┤ RY(pi/2) ├", - " ┌────┴─────┐└────┬─────┘", - "q_1: |0>┤ RY(pi/2) ├─────┼──────", - " └──────────┘ │ ", - "q_2: |0>─────────────────■──────", - " "]) + expected = '\n'.join([" ┌─────────┐", + "q_0: |0>─────■─────┤ RY(π/2) ├", + " ┌────┴────┐└────┬────┘", + "q_1: |0>┤ RY(π/2) ├─────┼─────", + " └─────────┘ │ ", + "q_2: |0>────────────────■─────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.cry(pi / 2, qr[0], qr[1]) @@ -402,13 +402,13 @@ def test_text_cry(self): def test_text_crx(self): """ crx drawing. """ - expected = '\n'.join([" ┌──────────┐", - "q_0: |0>─────■──────┤ RX(pi/2) ├", - " ┌────┴─────┐└────┬─────┘", - "q_1: |0>┤ RX(pi/2) ├─────┼──────", - " └──────────┘ │ ", - "q_2: |0>─────────────────■──────", - " "]) + expected = '\n'.join([" ┌─────────┐", + "q_0: |0>─────■─────┤ RX(π/2) ├", + " ┌────┴────┐└────┬────┘", + "q_1: |0>┤ RX(π/2) ├─────┼─────", + " └─────────┘ │ ", + "q_2: |0>────────────────■─────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.crx(pi / 2, qr[0], qr[1]) @@ -477,13 +477,13 @@ def test_text_ch(self): def test_text_rzz(self): """ rzz drawing. See #1957 """ - expected = '\n'.join([" ", - "q_0: |0>─■─────────────────", - " │zz(0) ", - "q_1: |0>─■───────■─────────", - " │zz(pi/2) ", - "q_2: |0>─────────■─────────", - " "]) + expected = '\n'.join([" ", + "q_0: |0>─■────────────────", + " │zz(0) ", + "q_1: |0>─■───────■────────", + " │zz(π/2) ", + "q_2: |0>─────────■────────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.rzz(0, qr[0], qr[1]) @@ -492,13 +492,13 @@ def test_text_rzz(self): def test_text_cu1(self): """ cu1 drawing. """ - expected = '\n'.join([" ", - "q_0: |0>─■──────■─────", - " │pi/2 │ ", - "q_1: |0>─■──────┼─────", - " │pi/2 ", - "q_2: |0>────────■─────", - " "]) + expected = '\n'.join([" ", + "q_0: |0>─■─────■────", + " │π/2 │ ", + "q_1: |0>─■─────┼────", + " │π/2 ", + "q_2: |0>───────■────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.cu1(pi / 2, qr[0], qr[1]) @@ -507,13 +507,13 @@ def test_text_cu1(self): def test_text_cu1_reverse_bits(self): """ cu1 drawing with reverse_bits""" - expected = '\n'.join([" ", - "q_2: |0>────────■─────", - " │ ", - "q_1: |0>─■──────┼─────", - " │pi/2 │pi/2 ", - "q_0: |0>─■──────■─────", - " "]) + expected = '\n'.join([" ", + "q_2: |0>───────■────", + " │ ", + "q_1: |0>─■─────┼────", + " │π/2 │π/2 ", + "q_0: |0>─■─────■────", + " "]) qr = QuantumRegister(3, 'q') circuit = QuantumCircuit(qr) circuit.cu1(pi / 2, qr[0], qr[1]) @@ -904,9 +904,9 @@ def test_rzz_on_wide_layer(self): """ Test a labeled gate (RZZ) in a wide layer. See https://github.com/Qiskit/qiskit-terra/issues/4838""" expected = '\n'.join([" ", - "q_0: |0>───────────────■───────────────────────", - " │zz(pi/2) ", - "q_1: |0>───────────────■───────────────────────", + "q_0: |0>────────────────■──────────────────────", + " │zz(π/2) ", + "q_1: |0>────────────────■──────────────────────", " ┌─────────────────────────────────────┐", "q_2: |0>┤ This is a really long long long box ├", " └─────────────────────────────────────┘"]) @@ -920,9 +920,9 @@ def test_cu1_on_wide_layer(self): """ Test a labeled gate (CU1) in a wide layer. See https://github.com/Qiskit/qiskit-terra/issues/4838""" expected = '\n'.join([" ", - "q_0: |0>─────────────────■─────────────────────", - " │pi/2 ", - "q_1: |0>─────────────────■─────────────────────", + "q_0: |0>──────────────────■────────────────────", + " │π/2 ", + "q_1: |0>──────────────────■────────────────────", " ┌─────────────────────────────────────┐", "q_2: |0>┤ This is a really long long long box ├", " └─────────────────────────────────────┘"]) @@ -1235,11 +1235,11 @@ class TestTextDrawerParams(QiskitTestCase): def test_text_parameters_mix(self): """ cu3 drawing with parameters""" - expected = '\n'.join([" ", - "q_0: |0>──────────■──────────", - " ┌─────────┴─────────┐", - "q_1: |0>┤ U3(pi/2,theta,pi) ├", - " └───────────────────┘"]) + expected = '\n'.join([" ", + "q_0: |0>─────────■─────────", + " ┌────────┴────────┐", + "q_1: |0>┤ U3(π/2,theta,π) ├", + " └─────────────────┘"]) qr = QuantumRegister(2, 'q') circuit = QuantumCircuit(qr) @@ -1250,9 +1250,9 @@ def test_text_parameters_mix(self): def test_text_bound_parameters(self): """Bound parameters See: https://github.com/Qiskit/qiskit-terra/pull/3876 """ - expected = '\n'.join([" ┌──────────────┐", - "qr_0: |0>┤ my_u2(pi,pi) ├", - " └──────────────┘"]) + expected = '\n'.join([" ┌────────────┐", + "qr_0: |0>┤ my_u2(π,π) ├", + " └────────────┘"]) my_u2_circuit = QuantumCircuit(1, name='my_u2') phi = Parameter('phi') @@ -1268,9 +1268,9 @@ def test_text_bound_parameters(self): def test_text_pi_param_expr(self): """Text pi in circuit with parameter expression.""" - expected = '\n'.join([" ┌───────────────────────┐", - "q_0: ┤ RX((pi - x)*(pi - y)) ├", - " └───────────────────────┘"]) + expected = '\n'.join([" ┌─────────────────────┐", + "q_0: ┤ RX((π - x)*(π - y)) ├", + " └─────────────────────┘"]) x, y = Parameter('x'), Parameter('y') circuit = QuantumCircuit(1) @@ -1662,15 +1662,15 @@ def test_text_conditional_cu3_ct(self): circuit = QuantumCircuit(qr, cr) circuit.cu3(pi / 2, pi / 2, pi / 2, qr[0], qr[1]).c_if(cr, 1) - expected = '\n'.join([" ", - "qr_0: |0>──────────■───────────", - " ┌─────────┴──────────┐", - "qr_1: |0>┤ U3(pi/2,pi/2,pi/2) ├", - " └─────────┬──────────┘", - "qr_2: |0>──────────┼───────────", - " ┌──┴──┐ ", - " cr_0: 0 ═══════╡ = 1 ╞════════", - " └─────┘ "]) + expected = '\n'.join([" ", + "qr_0: |0>─────────■─────────", + " ┌────────┴────────┐", + "qr_1: |0>┤ U3(π/2,π/2,π/2) ├", + " └────────┬────────┘", + "qr_2: |0>─────────┼─────────", + " ┌──┴──┐ ", + " cr_0: 0 ══════╡ = 1 ╞══════", + " └─────┘ "]) self.assertEqual(str(_text_circuit_drawer(circuit)), expected) @@ -1681,15 +1681,15 @@ def test_text_conditional_cu3_tc(self): circuit = QuantumCircuit(qr, cr) circuit.cu3(pi / 2, pi / 2, pi / 2, qr[1], qr[0]).c_if(cr, 1) - expected = '\n'.join([" ┌────────────────────┐", - "qr_0: |0>┤ U3(pi/2,pi/2,pi/2) ├", - " └─────────┬──────────┘", - "qr_1: |0>──────────■───────────", - " │ ", - "qr_2: |0>──────────┼───────────", - " ┌──┴──┐ ", - " cr_0: 0 ═══════╡ = 1 ╞════════", - " └─────┘ "]) + expected = '\n'.join([" ┌─────────────────┐", + "qr_0: |0>┤ U3(π/2,π/2,π/2) ├", + " └────────┬────────┘", + "qr_1: |0>─────────■─────────", + " │ ", + "qr_2: |0>─────────┼─────────", + " ┌──┴──┐ ", + " cr_0: 0 ══════╡ = 1 ╞══════", + " └─────┘ "]) self.assertEqual(str(_text_circuit_drawer(circuit)), expected) @@ -1886,9 +1886,9 @@ class TestTextNonRational(QiskitTestCase): def test_text_pifrac(self): """ u2 drawing with -5pi/8 fraction""" - expected = '\n'.join([" ┌───────────────┐", - "q_0: |0>┤ U2(pi,-5pi/8) ├", - " └───────────────┘"]) + expected = '\n'.join([" ┌─────────────┐", + "q_0: |0>┤ U2(π,-5π/8) ├", + " └─────────────┘"]) qr = QuantumRegister(1, 'q') circuit = QuantumCircuit(qr) @@ -1911,11 +1911,11 @@ def test_text_complex(self): def test_text_complex_pireal(self): """Complex numbers including pi show up in the text See https://github.com/Qiskit/qiskit-terra/issues/3640 """ - expected = '\n'.join([" ┌─────────────────────────────────┐", - "q_0: |0>┤0 ├", - " │ initialize(pi/10,0,0,0.94937j) │", - "q_1: |0>┤1 ├", - " └─────────────────────────────────┘" + expected = '\n'.join([" ┌────────────────────────────────┐", + "q_0: |0>┤0 ├", + " │ initialize(π/10,0,0,0.94937j) │", + "q_1: |0>┤1 ├", + " └────────────────────────────────┘" ]) ket = numpy.array([0.1 * numpy.pi, 0, 0, 0.9493702944526474 * 1j]) circuit = QuantumCircuit(2) @@ -1925,11 +1925,11 @@ def test_text_complex_pireal(self): def test_text_complex_piimaginary(self): """Complex numbers including pi show up in the text See https://github.com/Qiskit/qiskit-terra/issues/3640 """ - expected = '\n'.join([" ┌─────────────────────────────────┐", - "q_0: |0>┤0 ├", - " │ initialize(0.94937,0,0,pi/10j) │", - "q_1: |0>┤1 ├", - " └─────────────────────────────────┘" + expected = '\n'.join([" ┌────────────────────────────────┐", + "q_0: |0>┤0 ├", + " │ initialize(0.94937,0,0,π/10j) │", + "q_1: |0>┤1 ├", + " └────────────────────────────────┘" ]) ket = numpy.array([0.9493702944526474, 0, 0, 0.1 * numpy.pi * 1j]) circuit = QuantumCircuit(2) @@ -2209,15 +2209,15 @@ def test_c3h_middle(self): def test_c3u2(self): """Controlled Controlled U2""" expected = '\n'.join([ - " ", - "q_0: |0>────────■────────", - " ┌───────┴───────┐", - "q_1: |0>┤ U2(pi,-5pi/8) ├", - " └───────┬───────┘", - "q_2: |0>────────■────────", - " │ ", - "q_3: |0>────────■────────", - " "]) + " ", + "q_0: |0>───────■───────", + " ┌──────┴──────┐", + "q_1: |0>┤ U2(π,-5π/8) ├", + " └──────┬──────┘", + "q_2: |0>───────■───────", + " │ ", + "q_3: |0>───────■───────", + " "]) qr = QuantumRegister(4, 'q') circuit = QuantumCircuit(qr) circuit.append(U2Gate(pi, -5 * pi / 8).control(3), [qr[0], qr[3], qr[2], qr[1]]) @@ -2503,15 +2503,15 @@ def test_c3h_middle(self): def test_c3u2(self): """Controlled Controlled U2""" expected = '\n'.join([ - " ", - "q_0: |0>────────o────────", - " ┌───────┴───────┐", - "q_1: |0>┤ U2(pi,-5pi/8) ├", - " └───────┬───────┘", - "q_2: |0>────────■────────", - " │ ", - "q_3: |0>────────o────────", - " "]) + " ", + "q_0: |0>───────o───────", + " ┌──────┴──────┐", + "q_1: |0>┤ U2(π,-5π/8) ├", + " └──────┬──────┘", + "q_2: |0>───────■───────", + " │ ", + "q_3: |0>───────o───────", + " "]) qr = QuantumRegister(4, 'q') circuit = QuantumCircuit(qr) circuit.append(U2Gate(pi, -5 * pi / 8).control(3, ctrl_state='100'), @@ -2931,39 +2931,39 @@ def test_with_layout_but_disable(self): def test_after_transpile(self): """After transpile, the drawing should include the layout""" expected = '\n'.join([ - " ┌──────────┐┌──────────┐┌───┐┌──────────┐┌─┐ ", - " userqr_0 -> 0 ┤ U2(0,pi) ├┤ U2(0,pi) ├┤ X ├┤ U2(0,pi) ├┤M├───", - " ├──────────┤├──────────┤└─┬─┘├──────────┤└╥┘┌─┐", - " userqr_1 -> 1 ┤ U2(0,pi) ├┤ U2(0,pi) ├──■──┤ U2(0,pi) ├─╫─┤M├", - " └──────────┘└──────────┘ └──────────┘ ║ └╥┘", - " ancilla_0 -> 2 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_1 -> 3 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_2 -> 4 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_3 -> 5 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_4 -> 6 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_5 -> 7 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_6 -> 8 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_7 -> 9 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_8 -> 10 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " ancilla_9 -> 11 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - "ancilla_10 -> 12 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - "ancilla_11 -> 13 ──────────────────────────────────────────╫──╫─", - " ║ ║ ", - " c0_0: ══════════════════════════════════════════╩══╬═", - " ║ ", - " c0_1: ═════════════════════════════════════════════╩═", - " "]) + " ┌─────────┐┌─────────┐┌───┐┌─────────┐┌─┐ ", + " userqr_0 -> 0 ┤ U2(0,π) ├┤ U2(0,π) ├┤ X ├┤ U2(0,π) ├┤M├───", + " ├─────────┤├─────────┤└─┬─┘├─────────┤└╥┘┌─┐", + " userqr_1 -> 1 ┤ U2(0,π) ├┤ U2(0,π) ├──■──┤ U2(0,π) ├─╫─┤M├", + " └─────────┘└─────────┘ └─────────┘ ║ └╥┘", + " ancilla_0 -> 2 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_1 -> 3 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_2 -> 4 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_3 -> 5 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_4 -> 6 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_5 -> 7 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_6 -> 8 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_7 -> 9 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_8 -> 10 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " ancilla_9 -> 11 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + "ancilla_10 -> 12 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + "ancilla_11 -> 13 ───────────────────────────────────────╫──╫─", + " ║ ║ ", + " c0_0: ═══════════════════════════════════════╩══╬═", + " ║ ", + " c0_1: ══════════════════════════════════════════╩═", + " "]) qr = QuantumRegister(2, 'userqr') cr = ClassicalRegister(2, 'c0') @@ -3074,7 +3074,7 @@ class TestTextPhase(QiskitTestCase): def test_bell(self): """Text Bell state with phase.""" - expected = '\n'.join(["global phase: pi/2", + expected = '\n'.join(["global phase: \u03C0/2", " ┌───┐ ", "q_0: ┤ H ├──■──", " └───┘┌─┴─┐",