Skip to content

Commit 879777e

Browse files
Isort configured in the project and warning not handled properly
1 parent 6896a09 commit 879777e

File tree

3 files changed

+31
-34
lines changed

3 files changed

+31
-34
lines changed

mpqp/execution/result.py

-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
######################################
2-
# Copyright(C) 2021 - 2023 ColibrITD
3-
#
4-
# Developers :
5-
# - Hamza JAFFALI < hamza.jaffali@colibritd.com >
6-
# - Karla BAUMANN < karla.baumann@colibritd.com >
7-
# - Henri de BOUTRAY < henri.de.boutray@colibritd.com >
8-
#
9-
# Version : 0.1
10-
#
11-
# This file is part of QUICK.
12-
#
13-
# QUICK can not be copied and / or distributed without the express
14-
# permission of ColibrITD
15-
#
16-
######################################
171
from __future__ import annotations
182

193
import math

mpqp/qasm/qasm_to_braket.py

+23-17
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"""File regrouping all features for translating QASM code to Amazon Braket objects."""
22

33
import io
4-
import warnings
4+
5+
# import warnings
56
from logging import StreamHandler, getLogger
67

78
from braket.circuits import Circuit
89
from braket.ir.openqasm import Program
910
from typeguard import typechecked
1011

1112
from mpqp.qasm.open_qasm_2_and_3 import open_qasm_hard_includes
12-
from mpqp.tools.errors import UnsupportedBraketFeaturesWarning
13+
14+
# from mpqp.tools.errors import UnsupportedBraketFeaturesWarning
1315

1416

1517
@typechecked
@@ -57,28 +59,32 @@ def qasm3_to_braket_Circuit(qasm3_str: str) -> Circuit:
5759
# we remove any include of stdgates.inc and replace it with custom include
5860
qasm3_str = qasm3_str.replace("stdgates.inc", "braket_custom_include.inc")
5961

60-
try:
61-
after_stdgates_included = open_qasm_hard_includes(qasm3_str, set())
62-
except Exception as e:
63-
warning_message = (
64-
f"An error occurred while processing the OpenQASM code with Braket: {e}"
65-
)
66-
warnings.warn(warning_message, UnsupportedBraketFeaturesWarning)
67-
return None
68-
69-
# NOTE: gphase is already used in Braket and thus cannot be redefined as a native gate in OpenQASM.
70-
# We used ggphase instead
71-
if "U(" in after_stdgates_included or "gphase(" in after_stdgates_included:
72-
# Issue a warning only if not already issued
73-
warning_message = "This program uses OpenQASM language features that may not be supported on QPUs or on-demand simulators."
74-
warnings.warn(warning_message, UnsupportedBraketFeaturesWarning)
62+
after_stdgates_included = open_qasm_hard_includes(qasm3_str, set())
63+
# try:
64+
# except Exception as e:
65+
# warning_message = (
66+
# f"An error occurred while processing the OpenQASM code with Braket: {e}"
67+
# )
68+
# warnings.warn(warning_message, UnsupportedBraketFeaturesWarning)
69+
# return None
70+
71+
# # NOTE: gphase is already used in Braket and thus cannot be redefined as a native gate in OpenQASM.
72+
# # We used ggphase instead
73+
# if "U(" in after_stdgates_included or "gphase(" in after_stdgates_included:
74+
# # Issue a warning only if not already issued
75+
# warning_message = "This program uses OpenQASM language features that may not be supported on QPUs or on-demand simulators."
76+
# warnings.warn(warning_message, UnsupportedBraketFeaturesWarning)
7577

7678
# capture the Braket logger
7779
braket_logger = getLogger()
7880

81+
# TODO: catch the logged warning
7982
logger_output_stream = io.StringIO()
8083
stream_handler = StreamHandler(logger_output_stream)
8184
braket_logger.addHandler(stream_handler)
85+
# if message == warning_message:
86+
# warnings.warn(warning_message, UnsupportedBraketFeaturesWarning)
87+
stream_handler.addFilter(...)
8288

8389
circuit = Circuit.from_ir(after_stdgates_included)
8490

pyproject.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ build-backend = "setuptools.build_meta"
55

66
[tool.setuptools_scm]
77
version_scheme = "post-release"
8-
local_scheme = "no-local-version"
8+
local_scheme = "no-local-version"
9+
10+
[tool.isort]
11+
multi_line_output = 3
12+
include_trailing_comma = true
13+
force_grid_wrap = 0
14+
line_length = 88
15+
profile = "black"

0 commit comments

Comments
 (0)