microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
iadavis/pipeline-issue-debugging

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

45lines · 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 message += f"Options: {options}"
17 message += "\n"
18
19 try:
20 qasm_source = backend._qasm(circuit, **options)
21 message += "QASM source:"
22 message += "\n"
23 message += str(qasm_source)
24 except Exception as ex:
25 # if the conversion fails, print the circuit as a string
26 # as a fallback since we won't have the qasm source
27 message += "\nFailed converting QuantumCircuit to QASM:\n"
28 message += str(ex)
29 message += "\n"
30 message += "QuantumCircuit rendered:"
31 message += "\n"
32 circuit_str = str(circuit.draw(output="text"))
33 message += circuit_str
34 return message
35
36 try:
37 qsharp_source = backend._qsharp(circuit, **options)
38 message += "Q# source:"
39 message += "\n"
40 message += str(qsharp_source)
41 except Exception as ex:
42 message += "\nFailed converting QuantumCircuit to Q#:\n"
43 message += str(ex)
44
45 return message
46