Skip to content

Commit d7066ad

Browse files
Merge remote-tracking branch 'origin/dev' into dev
2 parents c88696e + df0869b commit d7066ad

File tree

3 files changed

+83
-77
lines changed

3 files changed

+83
-77
lines changed

mpqp/all.py

+40-41
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,62 @@
11
# pyright: reportUnusedImport=false
22
import numpy as np
3-
from . import QCircuit, Barrier, Language, Instruction
3+
4+
from mpqp.execution.providers_execution.atos_execution import get_result_from_qlm_job_id
5+
6+
from . import Barrier, Instruction, Language, QCircuit
7+
from .execution import (
8+
Job,
9+
JobStatus,
10+
JobType,
11+
Result,
12+
Sample,
13+
StateVector,
14+
adjust_measure,
15+
run,
16+
submit,
17+
)
18+
from .execution.connection.qlm_connection import get_all_job_ids
19+
from .execution.devices import ATOSDevice, AWSDevice, IBMDevice
20+
from .execution.vqa import Optimizer, minimize
421
from .gates import (
5-
X,
6-
Y,
7-
Z,
8-
H,
9-
P,
10-
S,
11-
T,
12-
SWAP,
13-
U,
14-
Rx,
15-
Ry,
16-
Rz,
17-
Rk,
1822
CNOT,
1923
CZ,
20-
CRk,
24+
SWAP,
2125
TOF,
2226
ControlledGate,
27+
CRk,
28+
CustomGate,
2329
Gate,
24-
ParametrizedGate,
25-
symbols,
2630
GateDefinition,
31+
H,
32+
Id,
2733
KrausRepresentation,
34+
P,
35+
ParametrizedGate,
2836
PauliDecomposition,
29-
CustomGate,
37+
Rk,
38+
Rx,
39+
Ry,
40+
Rz,
41+
S,
42+
T,
43+
U,
3044
UnitaryMatrix,
45+
X,
46+
Y,
47+
Z,
48+
symbols,
3149
)
3250
from .measures import (
33-
ComputationalBasis,
3451
Basis,
35-
HadamardBasis,
36-
VariableSizeBasis,
3752
BasisMeasure,
53+
ComputationalBasis,
3854
ExpectationMeasure,
39-
Observable,
55+
HadamardBasis,
4056
Measure,
57+
Observable,
58+
VariableSizeBasis,
4159
)
42-
from .execution import (
43-
Result,
44-
StateVector,
45-
Sample,
46-
run,
47-
adjust_measure,
48-
submit,
49-
Job,
50-
JobStatus,
51-
JobType,
52-
)
53-
from .execution.devices import (
54-
ATOSDevice,
55-
IBMDevice,
56-
AWSDevice,
57-
)
58-
from .execution.vqa import minimize, Optimizer
59-
from .execution.connection.qlm_connection import get_all_job_ids
60-
from mpqp.execution.providers_execution.atos_execution import get_result_from_qlm_job_id
6160
from .qasm import open_qasm_file_conversion_2_to_3, open_qasm_hard_includes
6261

6362
theta, k = symbols("θ k") # type: ignore
+16-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
# pyright: reportUnusedImport=false
22
from .controlled_gate import ControlledGate
3+
from .custom_gate import CustomGate, UnitaryMatrix
34
from .gate import Gate
4-
from .parametrized_gate import ParametrizedGate, symbols
5-
from .gate_definition import (
6-
GateDefinition,
7-
KrausRepresentation,
8-
PauliDecomposition,
9-
)
5+
from .gate_definition import GateDefinition, KrausRepresentation, PauliDecomposition
106
from .native_gates import (
11-
X,
12-
Y,
13-
Z,
7+
CNOT,
8+
CZ,
9+
SWAP,
10+
TOF,
11+
CRk,
1412
H,
13+
Id,
1514
P,
16-
S,
17-
T,
18-
SWAP,
19-
U,
15+
Rk,
2016
Rx,
2117
Ry,
2218
Rz,
23-
Rk,
24-
CNOT,
25-
CZ,
26-
CRk,
27-
TOF,
19+
S,
20+
T,
21+
U,
22+
X,
23+
Y,
24+
Z,
2825
)
29-
from .custom_gate import CustomGate, UnitaryMatrix
26+
from .parametrized_gate import ParametrizedGate, symbols

mpqp/core/instruction/gates/native_gates.py

+27-17
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,40 @@
1111

1212
import numpy as np
1313
import numpy.typing as npt
14-
1514
from qiskit.circuit import Parameter
1615
from qiskit.circuit.library import (
17-
ZGate,
18-
YGate,
1916
CCXGate,
17+
CPhaseGate,
18+
CXGate,
19+
CZGate,
20+
HGate,
21+
IGate,
2022
PhaseGate,
21-
SGate,
22-
UGate,
23-
TGate,
24-
SwapGate,
2523
RXGate,
2624
RYGate,
2725
RZGate,
28-
HGate,
29-
CXGate,
26+
SGate,
27+
SwapGate,
28+
TGate,
29+
UGate,
3030
XGate,
31-
CPhaseGate,
32-
CZGate,
31+
YGate,
32+
ZGate,
3333
)
3434
from sympy import Expr, pi
3535

3636
# pylance doesn't handle well Expr, so a lot of "type:ignore" will happen in
3737
# this file :/
3838
from typeguard import typechecked
3939

40-
from mpqp.core.languages import Language
41-
from mpqp.core.instruction.gates.gate import Gate, InvolutionGate, SingleQubitGate
4240
from mpqp.core.instruction.gates.controlled_gate import ControlledGate
41+
from mpqp.core.instruction.gates.gate import Gate, InvolutionGate, SingleQubitGate
4342
from mpqp.core.instruction.gates.gate_definition import UnitaryMatrix
4443
from mpqp.core.instruction.gates.parametrized_gate import ParametrizedGate
44+
from mpqp.core.languages import Language
4545
from mpqp.tools.generics import Matrix
46-
from mpqp.tools.maths import cos, sin, exp
46+
from mpqp.tools.maths import cos, exp, sin
47+
4748

4849
@typechecked
4950
def _qiskit_parameter_adder(param: Expr | float, qiskit_parameters: set[Parameter]):
@@ -162,6 +163,7 @@ class NoParameterGate(NativeGate, ABC):
162163
| CXGate
163164
| CZGate
164165
| CCXGate
166+
| IGate
165167
]
166168
"""Corresponding ``qiskit``'s gate class."""
167169
matrix: npt.NDArray[np.complex64]
@@ -194,11 +196,19 @@ def __init__(self, target: int):
194196

195197

196198
class Id(OneQubitNoParamGate, InvolutionGate):
197-
"""TODO hamza/muhammad
199+
"""One qubit identity gate.
200+
201+
Args:
202+
target: Index referring to the qubit on which the gate will be applied.
203+
204+
Example:
205+
>>> Id(0).to_matrix()
206+
array([[1, 0],
207+
[0, 1]])
198208
"""
199209

200-
qiskit_gate = ...
201-
matrix = ...
210+
qiskit_gate = IGate
211+
matrix = np.eye(2)
202212

203213

204214
class X(OneQubitNoParamGate, InvolutionGate):

0 commit comments

Comments
 (0)