Skip to content

Commit 31f3368

Browse files
Exploring error in custom gate
1 parent 5f8d50e commit 31f3368

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

mpqp/core/circuit.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ def to_other_language(
650650

651651
if isinstance(instruction, CustomGate):
652652
new_circ.unitary(instruction.to_other_language(), instruction.targets, instruction.label)
653-
#TODO hamza: to test, maybe need to reverse the order of elements in the matrix
653+
# FIXME: minus sign appearing when it should not, seems there a phase added somewhere, check u gate
654+
# in OpenQASM translation.
654655
continue
655656
elif isinstance(instruction, ControlledGate):
656657
qargs = instruction.controls + instruction.targets

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

0 commit comments

Comments
 (0)