hqm.circuits.circuit
1from typing import TypeVar, Generic 2import pennylane as qml 3import warnings 4 5quantumcircuit = TypeVar("quantumcircuit") 6class QuantumCircuit(Generic[quantumcircuit]): 7 ''' 8 Basic QuantumCircuit object. 9 ''' 10 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 11 ''' 12 QuantumCircuit parent class. 13 14 Parameters: 15 ----------- 16 - n_qubits : int 17 number of qubits for the quantum circuit 18 - n_layers : int 19 number of layers for the quantum circuit 20 - dev : qml.device 21 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 22 to 'default.qubit' 23 24 Returns: 25 -------- 26 Nothing, a QuantumCircuit object will be created. 27 ''' 28 29 # Checking for exceptions 30 if n_qubits < 1: raise Exception(f"Number of qubits must be greater or equal than 1, found {n_qubits}") 31 if n_layers < 1: raise Exception(f"Number of layers must be greater or equal than 1, found {n_layers}") 32 33 # Set dev to 'default.qubit' if dev is None 34 if dev is None: 35 dev = qml.device("default.qubit", wires=n_qubits) 36 warnings.warn(f"Dev has been set to None, setting it to {dev}") 37 38 self.n_qubits = n_qubits 39 self.n_layers = n_layers 40 self.dev = dev
class
QuantumCircuit(typing.Generic[~quantumcircuit]):
7class QuantumCircuit(Generic[quantumcircuit]): 8 ''' 9 Basic QuantumCircuit object. 10 ''' 11 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 12 ''' 13 QuantumCircuit parent class. 14 15 Parameters: 16 ----------- 17 - n_qubits : int 18 number of qubits for the quantum circuit 19 - n_layers : int 20 number of layers for the quantum circuit 21 - dev : qml.device 22 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 23 to 'default.qubit' 24 25 Returns: 26 -------- 27 Nothing, a QuantumCircuit object will be created. 28 ''' 29 30 # Checking for exceptions 31 if n_qubits < 1: raise Exception(f"Number of qubits must be greater or equal than 1, found {n_qubits}") 32 if n_layers < 1: raise Exception(f"Number of layers must be greater or equal than 1, found {n_layers}") 33 34 # Set dev to 'default.qubit' if dev is None 35 if dev is None: 36 dev = qml.device("default.qubit", wires=n_qubits) 37 warnings.warn(f"Dev has been set to None, setting it to {dev}") 38 39 self.n_qubits = n_qubits 40 self.n_layers = n_layers 41 self.dev = dev
Basic QuantumCircuit object.
QuantumCircuit( n_qubits: int, n_layers: int, dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'> = None)
11 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 12 ''' 13 QuantumCircuit parent class. 14 15 Parameters: 16 ----------- 17 - n_qubits : int 18 number of qubits for the quantum circuit 19 - n_layers : int 20 number of layers for the quantum circuit 21 - dev : qml.device 22 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 23 to 'default.qubit' 24 25 Returns: 26 -------- 27 Nothing, a QuantumCircuit object will be created. 28 ''' 29 30 # Checking for exceptions 31 if n_qubits < 1: raise Exception(f"Number of qubits must be greater or equal than 1, found {n_qubits}") 32 if n_layers < 1: raise Exception(f"Number of layers must be greater or equal than 1, found {n_layers}") 33 34 # Set dev to 'default.qubit' if dev is None 35 if dev is None: 36 dev = qml.device("default.qubit", wires=n_qubits) 37 warnings.warn(f"Dev has been set to None, setting it to {dev}") 38 39 self.n_qubits = n_qubits 40 self.n_layers = n_layers 41 self.dev = dev
QuantumCircuit parent class.
Parameters:
- n_qubits : int
number of qubits for the quantum circuit - n_layers : int
number of layers for the quantum circuit - dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set to 'default.qubit'
Returns:
Nothing, a QuantumCircuit object will be created.