From c4829e42ed527c9f519e86812827c7b0a375fd1d Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Wed, 6 Nov 2019 23:41:53 -0800 Subject: [PATCH 1/3] Bump qiskit version used during qasm compatibility test Fixes https://github.com/quantumlib/Cirq/issues/2509 --- cirq/testing/consistent_qasm.py | 4 ++-- dev_tools/conf/pip-list-dev-tools.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cirq/testing/consistent_qasm.py b/cirq/testing/consistent_qasm.py index 8940e392093..51dcb3ff531 100644 --- a/cirq/testing/consistent_qasm.py +++ b/cirq/testing/consistent_qasm.py @@ -70,7 +70,7 @@ def assert_qasm_is_consistent_with_unitary(val: Any): qasm_unitary = None try: result = qiskit.execute( - qiskit.load_qasm_string(qasm), + qiskit.QuantumCircuit.from_qasm_str(qasm), backend=qiskit.Aer.get_backend('unitary_simulator')) qasm_unitary = result.result().get_unitary() qasm_unitary = _reorder_indices_of_matrix( @@ -89,7 +89,7 @@ def assert_qasm_is_consistent_with_unitary(val: Any): p_unitary = None p_qasm_unitary = None raise AssertionError( - 'QASM be consistent with cirq.unitary(op) up to global phase.\n\n' + 'QASM not consistent with cirq.unitary(op) up to global phase.\n\n' 'op:\n{}\n\n' 'cirq.unitary(op):\n{}\n\n' 'Generated QASM:\n\n{}\n\n' diff --git a/dev_tools/conf/pip-list-dev-tools.txt b/dev_tools/conf/pip-list-dev-tools.txt index 45fe26fb589..2e08e4b23b9 100644 --- a/dev_tools/conf/pip-list-dev-tools.txt +++ b/dev_tools/conf/pip-list-dev-tools.txt @@ -14,7 +14,7 @@ mypy-protobuf==1.10 twine # For verifying behavior of qasm output. -qiskit~=0.6.0 +qiskit~=0.13.0 # For generating documentation. pypandoc From eaa4f863b0901940c0e315f11fc8eb5c2e8c9e40 Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Thu, 7 Nov 2019 14:25:54 -0800 Subject: [PATCH 2/3] format --- cirq/testing/consistent_qasm.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cirq/testing/consistent_qasm.py b/cirq/testing/consistent_qasm.py index 51dcb3ff531..7b559eac54f 100644 --- a/cirq/testing/consistent_qasm.py +++ b/cirq/testing/consistent_qasm.py @@ -96,14 +96,13 @@ def assert_qasm_is_consistent_with_unitary(val: Any): 'Unitary of generated QASM:\n{}\n\n' 'Phased matched cirq.unitary(op):\n{}\n\n' 'Phased matched unitary of generated QASM:\n{}\n\n' - 'Underlying error:\n{}'.format( - _indent(repr(op)), - _indent(repr(unitary)), - _indent(qasm), - _indent(repr(qasm_unitary)), - _indent(repr(p_unitary)), - _indent(repr(p_qasm_unitary)), - _indent(str(ex)))) + 'Underlying error:\n{}'.format(_indent(repr(op)), + _indent(repr(unitary)), + _indent(qasm), + _indent(repr(qasm_unitary)), + _indent(repr(p_unitary)), + _indent(repr(p_qasm_unitary)), + _indent(str(ex)))) def assert_qiskit_parsed_qasm_consistent_with_unitary(qasm, unitary): From 95f1bcfffdfad17c74070fccaf427340f6ed1b1e Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Thu, 7 Nov 2019 15:02:15 -0800 Subject: [PATCH 3/3] Fix reference --- cirq/testing/consistent_qasm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cirq/testing/consistent_qasm.py b/cirq/testing/consistent_qasm.py index 7b559eac54f..c8a4387232c 100644 --- a/cirq/testing/consistent_qasm.py +++ b/cirq/testing/consistent_qasm.py @@ -115,7 +115,7 @@ def assert_qiskit_parsed_qasm_consistent_with_unitary(qasm, unitary): return num_qubits = int(np.log2(len(unitary))) - result = qiskit.execute(qiskit.load_qasm_string(qasm), + result = qiskit.execute(qiskit.QuantumCircuit.from_qasm_str(qasm), backend=qiskit.Aer.get_backend('unitary_simulator')) qiskit_unitary = result.result().get_unitary() qiskit_unitary = _reorder_indices_of_matrix(