diff --git a/src/quafu/circuits/quantum_circuit.py b/src/quafu/circuits/quantum_circuit.py index 6e7ccd7..c947713 100644 --- a/src/quafu/circuits/quantum_circuit.py +++ b/src/quafu/circuits/quantum_circuit.py @@ -56,7 +56,7 @@ def parameterized_gates(self): @property def num(self): - return np.sum([len(qreg) for qreg in self.qregs]) + return sum([len(qreg) for qreg in self.qregs]) @property def used_qubits(self) -> List: @@ -428,10 +428,9 @@ def wrap_to_gate(self, name: str): Wrap the circuit to a subclass of QuantumGate, create by metaclass. """ # TODO: error check - from instruction.qu_gate.quantum_gate import customize_gate - customized = customize_gate(cls_name=name.capitalize(), - sd_name=name, - qubit_num=self.qbit_num, + from quafu.elements.quantum_element.quantum_gate import customize_gate + customized = customize_gate(cls_name=name.lower(), + qubit_num=self.num, gate_structure=self.gates) return customized diff --git a/src/quafu/elements/quantum_element/quantum_gate.py b/src/quafu/elements/quantum_element/quantum_gate.py index a5653dd..e41cf22 100644 --- a/src/quafu/elements/quantum_element/quantum_gate.py +++ b/src/quafu/elements/quantum_element/quantum_gate.py @@ -1,3 +1,17 @@ +# (C) Copyright 2023 Beijing Academy of Quantum Information Sciences +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from abc import ABC, abstractmethod, ABCMeta from typing import List, Union, Iterable