microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.19.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/pip/tests-integration/interop_qiskit/test_circuits/__init__.py

43lines · modecode

1# Copyright (c) Microsoft Corporation.
2# Licensed under the MIT License.
3
4from .test_circuits import *
5
6
7def generate_repro_information(
8 circuit: "QuantumCircuit", backend: "QSharpBackend", **options
9):
10 name = circuit.name
11 profile_name = str(backend.options.target_profile)
12 message = f"Error with Qiskit circuit '{name}'."
13 message += "\n"
14 message += f"Profile: {profile_name}"
15 message += "\n"
16
17 try:
18 qasm_source = backend._qasm(circuit, **options)
19 message += "QASM source:"
20 message += "\n"
21 message += str(qasm_source)
22 except Exception as ex:
23 # if the conversion fails, print the circuit as a string
24 # as a fallback since we won't have the qasm source
25 message += "\nFailed converting QuantumCircuit to QASM:\n"
26 message += str(ex)
27 message += "\n"
28 message += "QuantumCircuit rendered:"
29 message += "\n"
30 circuit_str = str(circuit.draw(output="text"))
31 message += circuit_str
32 return message
33
34 try:
35 qsharp_source = backend._qsharp(circuit, **options)
36 message += "Q# source:"
37 message += "\n"
38 message += str(qsharp_source)
39 except Exception as ex:
40 message += "\nFailed converting QuantumCircuit to Q#:\n"
41 message += str(ex)
42
43 return message
44