Skip to content

Commit 1bbabb0

Browse files
Merge pull request #15 from ColibrITD-SAS/dev
pipy: solving the images problem
2 parents 2e37669 + af7f05a commit 1bbabb0

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![doc status badge](https://img.shields.io/github/actions/workflow/status/ColibrITD-SAS/mpqp/doc.yml?label=doc)
44
![pipy deployment status badge](https://img.shields.io/github/actions/workflow/status/ColibrITD-SAS/mpqp/pipy.yml?label=pipy)
55

6-
![[alt:mpqp logo]](resources/dark-logo.png)
6+
![[alt:mpqp logo]](resources/dark-logo.svg)
77

88
# The MPQP library
99

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115

116116
# The theme to use for HTML and HTML Help pages. See the documentation for
117117
# a list of builtin themes.
118+
# `html_theme` is not needed since we use a plugin to have the dark theme RTD,
119+
# so `html_theme` is overridden anyway.
118120
# html_theme = "alabaster"
119-
# html_theme = "furo" # pip install furo
120-
# html_theme = "sphinx_rtd_theme" # pip install sphinx-rtd-theme
121121
html_context = {
122122
"github_user": "ColibrITD",
123123
"github_repo": "mpqp",

mpqp/core/circuit.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from matplotlib.figure import Figure
1010
from qiskit.circuit import QuantumCircuit, Operation
1111
from qiskit.circuit.quantumcircuit import CircuitInstruction
12+
1213
from qat.core.wrappers.circuit import Circuit as myQLM_Circuit
1314
from braket.circuits import Circuit as braket_Circuit
15+
from qiskit.quantum_info import Operator
1416
from sympy import Basic, Expr
1517
from typeguard import typechecked, TypeCheckError
1618

@@ -643,17 +645,23 @@ def to_other_language(
643645
Language.QISKIT, qiskit_parameters
644646
)
645647
assert isinstance(qiskit_inst, CircuitInstruction) or isinstance(
646-
qiskit_inst, Operation
647-
)
648+
qiskit_inst, Operation) or isinstance(qiskit_inst, Operator)
648649
cargs = []
649650

650-
if isinstance(instruction, ControlledGate):
651+
if isinstance(instruction, CustomGate):
652+
new_circ.unitary(instruction.to_other_language(), instruction.targets, instruction.label)
653+
# FIXME: minus sign appearing when it should not, seems there a phase added somewhere, check u gate
654+
# in OpenQASM translation.
655+
continue
656+
elif isinstance(instruction, ControlledGate):
651657
qargs = instruction.controls + instruction.targets
652658
elif isinstance(instruction, Gate):
653659
qargs = instruction.targets
654660
elif isinstance(instruction, BasisMeasure) and isinstance(
655661
instruction.basis, ComputationalBasis
656662
):
663+
#TODO muhammad/henri, for custom basis, check if something should be changed here, otherwise remove
664+
# the condition to have only computational basis
657665
assert instruction.c_targets is not None
658666
qargs = [instruction.targets]
659667
cargs = [instruction.c_targets]

mpqp/core/instruction/gates/custom_gate.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from mpqp.core.languages import Language
1212
from qiskit.circuit import Parameter
13+
from qiskit.quantum_info.operators import Operator as QiskitOperator
1314

1415

1516
@typechecked
@@ -39,7 +40,7 @@ def to_other_language(
3940
):
4041
if qiskit_parameters is None:
4142
qiskit_parameters = set()
42-
return super().to_other_language(language, qiskit_parameters)
43+
return QiskitOperator(self.matrix)
4344

4445
def decompose(self):
4546
"""Returns the circuit made of native gates equivalent to this gate.

mpqp/core/instruction/gates/native_gates.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from mpqp.tools.generics import Matrix
4646
from mpqp.tools.maths import cos, sin, exp
4747

48-
4948
@typechecked
5049
def _qiskit_parameter_adder(param: Expr | float, qiskit_parameters: set[Parameter]):
5150
"""To avoid having several parameters in qiskit for the same value we keep
@@ -194,6 +193,14 @@ def __init__(self, target: int):
194193
SingleQubitGate.__init__(self, target, type(self).__name__)
195194

196195

196+
class Id(OneQubitNoParamGate, InvolutionGate):
197+
"""TODO hamza/muhammad
198+
"""
199+
200+
qiskit_gate = ...
201+
matrix = ...
202+
203+
197204
class X(OneQubitNoParamGate, InvolutionGate):
198205
"""One qubit X (NOT) Pauli gate.
199206
@@ -625,3 +632,8 @@ def to_matrix(self) -> Matrix:
625632
m = np.identity(8, dtype=complex)
626633
m[-2:, -2:] = np.ones(2) - np.identity(2)
627634
return m
635+
636+
637+
NATIVE_GATES = [CNOT, CRk, CZ, H, Id, P, Rk, Rx, Ry, Rz, S, SWAP, T, TOF, U, X, Y, Z]
638+
# TODO : check the possibility to detect when a custom gate can be defined as a native gate, problem with
639+
# parametrized gates maybe

resources/mpqp-usage.png

2.19 MB
Loading

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
with open("README.md", "r") as f:
44
long_description = f.read()
55

6+
long_description = long_description.replace(".svg", ".png").replace(".gif", ".png")
7+
68
with open("LICENSE", "r") as f:
79
license = f.readline()
810

0 commit comments

Comments
 (0)