From bb0da079b484463619fd68e17140518a567a8da8 Mon Sep 17 00:00:00 2001 From: Andrea Papaluca Date: Mon, 26 Feb 2024 11:00:30 +0400 Subject: [PATCH] fix: fixing suggestions --- src/qibo/_openqasm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qibo/_openqasm.py b/src/qibo/_openqasm.py index cb2e7d3c5a..3c175e29ba 100644 --- a/src/qibo/_openqasm.py +++ b/src/qibo/_openqasm.py @@ -2,10 +2,12 @@ from typing import Union +import numpy as np import openqasm3 import qibo from qibo.config import raise_error +from qibo.gates import FusedGate class DefinedGate: @@ -145,7 +147,7 @@ def _get_qubit(self, qubit): def _get_gate(self, gate): """Converts a :class:`openqasm3.ast.QuantumGate` statement - into :class:`qibo.gates.measurements.M`.""" + into :class:`qibo.gates.Gate`.""" qubits = [self._get_qubit(q) for q in gate.qubits] init_args = [] for arg in gate.arguments: @@ -155,6 +157,7 @@ def _get_gate(self, gate): except: pass init_args.append(arg) + # check whether the gate exists in qibo.gates already try: gates = [ getattr(qibo.gates, _qibo_gate_name(gate.name.name))( @@ -163,6 +166,7 @@ def _get_gate(self, gate): ] except: try: + # check whether the gate was defined by the user gates = self.defined_gates.get(gate.name.name).get_gates( qubits, init_args )