Skip to content

Commit 1d7dd57

Browse files
Merge pull request #114 from ColibrITD-SAS/dev
pre-version patch
2 parents 2434cdc + 3bc2470 commit 1d7dd57

File tree

8 files changed

+69
-40
lines changed

8 files changed

+69
-40
lines changed

examples/notebooks/1_Basics_of_circuit.ipynb

+11-9
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@
220220
"cell_type": "code",
221221
"execution_count": 9,
222222
"id": "50e96aae",
223-
"metadata": {"tags": [
224-
"skip-execution"
225-
]},
223+
"metadata": {
224+
"tags": [
225+
"skip-execution"
226+
]
227+
},
226228
"outputs": [
227229
{
228230
"data": {
@@ -315,7 +317,7 @@
315317
},
316318
{
317319
"cell_type": "code",
318-
"execution_count": 13,
320+
"execution_count": null,
319321
"id": "780d0208",
320322
"metadata": {},
321323
"outputs": [
@@ -331,7 +333,7 @@
331333
}
332334
],
333335
"source": [
334-
"circ3.get_measurements()"
336+
"circ3.measurements"
335337
]
336338
},
337339
{
@@ -569,7 +571,7 @@
569571
},
570572
{
571573
"cell_type": "code",
572-
"execution_count": 21,
574+
"execution_count": null,
573575
"id": "c39e3e72",
574576
"metadata": {},
575577
"outputs": [
@@ -596,12 +598,12 @@
596598
}
597599
],
598600
"source": [
599-
"print(circ3.to_qasm2())"
601+
"print(circ3.to_other_language(Language.QASM2))"
600602
]
601603
},
602604
{
603605
"cell_type": "code",
604-
"execution_count": 22,
606+
"execution_count": null,
605607
"id": "0cdb44e5",
606608
"metadata": {},
607609
"outputs": [
@@ -629,7 +631,7 @@
629631
}
630632
],
631633
"source": [
632-
"print(circ3.to_qasm3())"
634+
"print(circ3.to_other_language(Language.QASM3))"
633635
]
634636
},
635637
{

examples/scripts/open_qasm_conversions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
barrier q;"""
5353

5454
# this exemple should be executed from mpqp root
55-
print(open_qasm_2_to_3(qasm2_3, path_to_file="."))
55+
print(open_qasm_2_to_3(qasm2_3, path_to_file="./examples/scripts"))
5656

5757
print("-------------------------")
5858
print("-------------------------")

mpqp/execution/simulated_devices.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ def is_remote(self) -> bool:
3939
class StaticIBMSimulatedDevice(SimulatedDevice):
4040
"""A class regrouping methods specific to an ``IBMSimulatedDevice``."""
4141

42+
def supports_observable(self) -> bool:
43+
return True
44+
45+
def supports_observable_ideal(self) -> bool:
46+
return True
47+
48+
def supports_samples(self) -> bool:
49+
return False
50+
4251
def supports_state_vector(self):
4352
return False
4453

@@ -58,13 +67,16 @@ def to_noise_model(self) -> "Qiskit_NoiseModel":
5867
@staticmethod
5968
def get_ibm_fake_providers() -> list[tuple[str, type["FakeBackendV2"]]]:
6069
from qiskit_ibm_runtime import fake_provider
70+
from qiskit_ibm_runtime.fake_provider.fake_backend import FakeBackendV2
6171

6272
fake_imports = fake_provider.__dict__
6373
return [
64-
(p, fake_imports[p])
65-
for p in fake_imports
66-
if p.startswith("Fake")
67-
and not p.startswith(("FakeProvider", "FakeFractional"))
74+
(name, device)
75+
for name, device in fake_imports.items()
76+
if name.startswith("Fake")
77+
and not name.startswith(("FakeProvider", "FakeFractional"))
78+
and issubclass(device, FakeBackendV2)
79+
and "cairo" not in name.lower()
6880
]
6981

7082

mpqp/noise/__init__.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
from mpqp.noise.noise_model import *
1+
# pyright: reportUnusedImport=false
2+
from mpqp.noise.noise_model import (
3+
AmplitudeDamping,
4+
BitFlip,
5+
Depolarizing,
6+
DimensionalNoiseModel,
7+
NoiseModel,
8+
PhaseDamping,
9+
)

mpqp/tools/display.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
import numpy as np
77
import numpy.typing as npt
8-
from sympy import Basic
98

109
if TYPE_CHECKING:
11-
from sympy import Expr
10+
from sympy import Expr, Basic
1211

1312
from typeguard import typechecked
1413

pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ filterwarnings =
2626
ignore: Treating CircuitInstruction as an iterable is deprecated.*:DeprecationWarning
2727
ignore:The qiskit.extensions module is pending deprecation.*:PendingDeprecationWarning
2828
ignore:Building a flow controller with keyword arguments is going to be deprecated.*:PendingDeprecationWarning
29+
ignore:The class ``qiskit.qobj.pulse_qobj.PulseQobjInstruction`` is deprecated as of qiskit 1.2.*:DeprecationWarning
30+
ignore:The class ``qiskit.qobj.pulse_qobj.PulseLibraryItem`` is deprecated as of qiskit 1.2.*:DeprecationWarning
2931
; others
3032
; pyreadline
3133
ignore:Using or importing the ABCs from.*:DeprecationWarning

tests/execution/test_validity.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def test_sample_counts_in_trust_interval(instructions: list[Gate]):
266266
c = QCircuit(instructions)
267267
shots = 50000
268268
err_rate = 0.2
269-
err_rate_pourcentage = 1 - np.power(1 - err_rate, (1 / 2))
269+
err_rate_percentage = 1 - np.power(1 - err_rate, (1 / 2))
270270
res = run(c, state_vector_devices[0])
271271
assert isinstance(res, Result)
272272
expected_counts = [int(count) for count in np.round(shots * res.probabilities)]
@@ -281,7 +281,7 @@ def test_sample_counts_in_trust_interval(instructions: list[Gate]):
281281
# check if the true value is inside the trust interval
282282
for i in range(len(counts)):
283283
trust_interval = np.ceil(
284-
err_rate_pourcentage * expected_counts[i] + shots / 15
284+
err_rate_percentage * expected_counts[i] + shots / 15
285285
)
286286
print(trust_interval)
287287
assert (

tests/test_doc.py

+27-21
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from functools import partial
88
from types import TracebackType
99
from typing import Any, Optional, Type
10-
from anytree import Node
1110

1211
import pytest
12+
from anytree import Node
1313
from dotenv import dotenv_values, set_key, unset_key
14+
from numpy.random import default_rng
15+
1416
from mpqp.all import *
1517
from mpqp.core.instruction.measurement import pauli_string
1618
from mpqp.core.instruction.measurement.pauli_string import PauliString
@@ -25,41 +27,40 @@
2527
from mpqp.execution.providers.aws import estimate_cost_single_job
2628
from mpqp.execution.runner import generate_job
2729
from mpqp.noise.noise_model import _plural_marker # pyright: ignore[reportPrivateUsage]
28-
from mpqp.tools.display import clean_1D_array, clean_matrix, pprint, format_element
29-
from mpqp.tools.circuit import random_circuit, random_gate, random_noise
30+
from mpqp.qasm import (
31+
qasm2_to_cirq_Circuit,
32+
qasm2_to_myqlm_Circuit,
33+
qasm2_to_Qiskit_Circuit,
34+
qasm3_to_braket_Program,
35+
)
3036
from mpqp.qasm.mpqp_to_qasm import mpqp_to_qasm2
3137
from mpqp.qasm.open_qasm_2_and_3 import (
38+
convert_instruction_3_to_2,
3239
open_qasm_2_to_3,
33-
parse_user_gates,
34-
remove_user_gates,
3540
open_qasm_3_to_2,
36-
convert_instruction_3_to_2,
3741
open_qasm_file_conversion_3_to_2,
42+
parse_user_gates,
3843
remove_include_and_comment,
39-
)
40-
from mpqp.qasm.qasm_to_mpqp import qasm2_parse
41-
from mpqp.qasm import (
42-
qasm2_to_Qiskit_Circuit,
43-
qasm2_to_cirq_Circuit,
44-
qasm2_to_myqlm_Circuit,
45-
qasm3_to_braket_Program,
44+
remove_user_gates,
4645
)
4746
from mpqp.qasm.qasm_to_braket import qasm3_to_braket_Circuit
48-
from mpqp.tools.maths import (
49-
is_hermitian,
50-
is_unitary,
51-
normalize,
52-
rand_orthogonal_matrix,
53-
is_power_of_two,
54-
)
47+
from mpqp.qasm.qasm_to_mpqp import qasm2_parse
48+
from mpqp.tools.circuit import random_circuit, random_gate, random_noise
5549
from mpqp.tools.display import *
50+
from mpqp.tools.display import clean_1D_array, clean_matrix, format_element, pprint
5651
from mpqp.tools.errors import (
5752
OpenQASMTranslationWarning,
5853
UnsupportedBraketFeaturesWarning,
5954
)
6055
from mpqp.tools.generics import find, find_index, flatten
6156
from mpqp.tools.maths import *
62-
from numpy.random import default_rng
57+
from mpqp.tools.maths import (
58+
is_hermitian,
59+
is_power_of_two,
60+
is_unitary,
61+
normalize,
62+
rand_orthogonal_matrix,
63+
)
6364

6465
sys.path.insert(0, os.path.abspath("."))
6566

@@ -123,6 +124,11 @@ def run_doctest(root: str, filename: str, monkeypatch: pytest.MonkeyPatch):
123124
monkeypatch.setattr('numpy.random.default_rng', stable_random)
124125
warnings.filterwarnings("ignore", category=UnsupportedBraketFeaturesWarning)
125126
warnings.filterwarnings("ignore", category=OpenQASMTranslationWarning)
127+
warnings.filterwarnings(
128+
"ignore",
129+
category=UserWarning,
130+
message=r".*Noise is not applied to any gate, as there is no eligible gate in the circuit.*",
131+
)
126132
assert True
127133
my_module = importlib.import_module(
128134
os.path.join(root, filename)

0 commit comments

Comments
 (0)