blueqatパッケージ¶
Submodules¶
blueqat.circuit module¶
This module defines Circuit and the setting for circuit.
-
class
blueqat.circuit.
BlueqatGlobalSetting
[ソース]¶ ベースクラス:
object
Setting for Blueqat.
-
static
get_default_backend_name
()[ソース]¶ Get the default backend name.
- Returns:
- str: The name of default backend.
-
static
register_backend
(name, backend, allow_overwrite=False)[ソース]¶ Register new backend.
- Args:
- name (str): The name of backend.gateclass (type): The type object of backendallow_overwrite (bool, optional): If True, allow to overwrite the existing backend.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing backend.
- When allow_overwrite=True, this error is not raised.
-
static
register_gate
(name, gateclass, allow_overwrite=False)[ソース]¶ Register new gate to gate set.
- Args:
- name (str): The name of gate.gateclass (type): The type object of gate.allow_overwrite (bool, optional): If True, allow to overwrite the existing gate.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing gate.
- When allow_overwrite=True, this error is not raised.
-
static
register_macro
(name: str, func: Callable, allow_overwrite: bool = False) → None[ソース]¶ Register new macro to Circuit.
- Args:
- name (str): The name of macro.func (callable): The function to be called.allow_overwrite (bool, optional): If True, allow to overwrite the existing macro.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing macro, gate or method.
- When allow_overwrite=True, this error is not raised.
-
static
set_default_backend
(name)[ソース]¶ Set the default backend to be used by Circuit. Args:
name (str): The name of the default backend.- Raises:
- ValueError: Specified backend is not registered.
-
static
unregister_backend
(name)[ソース]¶ Unregister a backend.
- Args:
- name (str): The name of the backend to be unregistered.
- Raises:
- ValueError: Specified backend is not registered.
-
static
-
class
blueqat.circuit.
Circuit
(n_qubits=0, ops=None)[ソース]¶ ベースクラス:
object
Store the gate operations and call the backends.
-
copy
(copy_backends=True, copy_default_backend=True, copy_cache=None, copy_history=None)[ソース]¶ Copy the circuit.
- params:
- copy_backends :bool copy backends if True.copy_default_backend :bool copy default_backend if True.
-
dagger
(ignore_measurement=False, copy_backends=False, copy_default_backend=True)[ソース]¶ Make Hermitian conjugate of the circuit.
This feature is beta. Interface may be changed.
- ignore_measurement (bool, optional):
- If True, ignore the measurement in the circuit.Otherwise, if measurement in the circuit, raises ValueError.
-
get_default_backend_name
()[ソース]¶ Get the default backend of this circuit or global setting.
- Returns:
- str: The name of default backend.
-
make_cache
(backend=None)[ソース]¶ Make a cache to reduce the time of run. Some backends may implemented it.
This is temporary API. It may changed or deprecated.
-
run
(*args, backend=None, **kwargs)[ソース]¶ Run the circuit.
Circuit have several backends. When backend parameter is specified, use specified backend, and otherwise, default backend is used. Other parameters are passed to the backend.
The meaning of parameters are depends on the backend specifications. However, following parameters are commonly used.
- Commonly used args (Depends on backend):
- shots (int, optional): The number of sampling the circuit.returns (str, optional): The category of returns value.e.g. "statevector" returns the state vector after run the circuit."shots" returns the counter of measured value.token, url (str, optional): The token and URL for cloud resource.
- Returns:
- Depends on backend.
- Raises:
- Depends on backend.
-
set_default_backend
(backend_name)[ソース]¶ Set the default backend of this circuit.
This setting is only applied for this circuit. If you want to change the default backend of all gates, use BlueqatGlobalSetting.set_default_backend().
After set the default backend by this method, global setting is ignored even if BlueqatGlobalSetting.set_default_backend() is called. If you want to use global default setting, call this method with backend_name=None.
- Args:
- backend_name (str or None): new default backend name.If None is given, global setting is applied.
- Raises:
- ValueError: If backend_name is not registered backend.
-
blueqat.gate module¶
gate module implements quantum gate operations. This module is internally used.
-
class
blueqat.gate.
CCZGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.Gate
2-Controlled Z gate
-
lowername
= 'ccz'¶
-
-
class
blueqat.gate.
CHGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled-H gate
-
lowername
= 'ch'¶
-
-
class
blueqat.gate.
CPhaseGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-Z gate but phase is different.
-
lowername
= 'cphase'¶
-
-
class
blueqat.gate.
CRXGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-X gate
-
lowername
= 'crx'¶
-
-
class
blueqat.gate.
CRYGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-Y gate
-
lowername
= 'cry'¶
-
-
class
blueqat.gate.
CRZGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-Z gate
-
lowername
= 'crz'¶
-
-
class
blueqat.gate.
CSwapGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.Gate
Controlled SWAP gate
-
lowername
= 'cswap'¶
-
-
class
blueqat.gate.
CU1Gate
(targets, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled U1 gate
U1 gate is as same as RZ gate and CU1 gate is as same as CPhase gate. It is because for compatibility with IBM's implementations.
You should probably use RZ/CRZ gates or Phase/CPhase gates instead of U1/CU1 gates.
-
lowername
= 'cu1'¶
-
-
class
blueqat.gate.
CU2Gate
(targets, phi, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled U2 gate
-
lowername
= 'cu2'¶
-
-
class
blueqat.gate.
CU3Gate
(targets, theta, phi, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled U3 gate
-
lowername
= 'cu3'¶
-
-
class
blueqat.gate.
CXGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled-X (CNOT) gate
-
lowername
= 'cx'¶
-
-
class
blueqat.gate.
CYGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled-Y gate
-
lowername
= 'cy'¶
-
-
class
blueqat.gate.
CZGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Controlled-Z gate
-
lowername
= 'cz'¶
-
-
class
blueqat.gate.
Gate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
abc.ABC
Abstract quantum gate class.
-
fallback
(n_qubits: int) → List[blueqat.gate.Gate][ソース]¶ Returns alternative gates to make equivalent circuit.
-
lowername
= None¶
-
uppername
¶ Upper name of the gate.
-
-
class
blueqat.gate.
HGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Hadamard gate
-
lowername
= 'h'¶
-
-
class
blueqat.gate.
IGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Identity gate
-
lowername
= 'i'¶
-
-
class
blueqat.gate.
Measurement
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Measurement operation
-
lowername
= 'measure'¶
-
-
class
blueqat.gate.
OneQubitGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.Gate
Abstract quantum gate class for 1 qubit gate.
-
class
blueqat.gate.
PhaseGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Rotate-Z gate but global phase is different.
Global phase doesn't makes any difference of measured result. You may use RZ gate or U1 gate instead, but distinguishing these gates may better for debugging or future improvement.
furthermore, phase gate may efficient for simulating. (It depends on backend implementation. But matrix of phase gate is simpler than RZ gate or U1 gate.)
-
lowername
= 'phase'¶
-
-
class
blueqat.gate.
RXGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Rotate-X gate
-
lowername
= 'rx'¶
-
-
class
blueqat.gate.
RXXGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-XX gate
-
lowername
= 'rxx'¶
-
-
class
blueqat.gate.
RYGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Rotate-Y gate
-
lowername
= 'ry'¶
-
-
class
blueqat.gate.
RYYGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-YY gate
-
lowername
= 'ryy'¶
-
-
class
blueqat.gate.
RZGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Rotate-Z gate
-
lowername
= 'rz'¶
-
-
class
blueqat.gate.
RZZGate
(targets, theta, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Rotate-ZZ gate
-
lowername
= 'rzz'¶
-
-
class
blueqat.gate.
Reset
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Reset operation
-
lowername
= 'reset'¶
-
-
class
blueqat.gate.
SDagGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Dagger of S gate
-
lowername
= 'sdg'¶
-
-
class
blueqat.gate.
SGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
S gate
-
lowername
= 's'¶
-
-
class
blueqat.gate.
SwapGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.TwoQubitGate
Swap gate
-
lowername
= 'swap'¶
-
-
class
blueqat.gate.
TDagGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Dagger of T ($pi/8$) gate
-
lowername
= 'tdg'¶
-
-
class
blueqat.gate.
TGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
T ($pi/8$) gate
-
lowername
= 't'¶
-
-
class
blueqat.gate.
ToffoliGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.Gate
Toffoli (CCX) gate
-
lowername
= 'ccx'¶
-
-
class
blueqat.gate.
TwoQubitGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.Gate
Abstract quantum gate class for 2 qubits gate.
-
class
blueqat.gate.
U1Gate
(targets, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
U1 gate
U1 gate is as same as RZ gate and CU1 gate is as same as CPhase gate. It is because for compatibility with IBM's implementations.
You should probably use RZ/CRZ gates or Phase/CPhase gates instead of U1/CU1 gates.
-
lowername
= 'u1'¶
-
-
class
blueqat.gate.
U2Gate
(targets, phi, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
U2 gate
-
lowername
= 'u2'¶
-
-
class
blueqat.gate.
U3Gate
(targets, theta, phi, lambd, **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
U3 gate
-
lowername
= 'u3'¶
-
-
class
blueqat.gate.
XGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Pauli's X gate
-
lowername
= 'x'¶
-
-
class
blueqat.gate.
YGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Pauli's Y gate
-
lowername
= 'y'¶
-
-
class
blueqat.gate.
ZGate
(targets, params=(), **kwargs)[ソース]¶ ベースクラス:
blueqat.gate.OneQubitGate
Pauli's Z gate
-
lowername
= 'z'¶
-
blueqat.pauli module¶
The module for calculate Pauli matrices.
-
class
blueqat.pauli.
Expr
[ソース]¶ ベースクラス:
blueqat.pauli._ExprTuple
-
max_n
()[ソース]¶ Returns the maximum index of Pauli matrices in the Expr. If Expr is empty or only constant and identity matrix, returns -1.
-
is_identity
¶ If self is I, returns True, otherwise False.
-
n_qubits
¶ Returns the number of qubits of the Term.
If Expr is empty or only constant and identity matrix, returns 0.
-
-
class
blueqat.pauli.
Term
[ソース]¶ ベースクラス:
blueqat.pauli._TermTuple
Multiplication of Pauli matrices with coefficient. Note that this class is immutable.
Multiplied Pauli matrices are very important for quantum computation because it is an unitary matrix (without coefficient) and also it can be consider the time evolution of the term (with real coefficient) without Suzuki-Trotter expansion.
-
static
from_chars
(chars)[ソース]¶ Make Pauli's Term from chars which is written by "X", "Y", "Z" or "I". e.g. "XZIY" => X(0) * Z(1) * Y(3)
- Args:
- chars (str): Written in "X", "Y", "Z" or "I".
- Returns:
- Term: A Term object.
- Raises:
- ValueError: When chars conteins the character which is "X", "Y", "Z" nor "I".
-
get_time_evolution
()[ソース]¶ Get the function to append the time evolution of this term.
- Returns:
- function(circuit: Circuit, t: float):
- Add gates for time evolution to circuit with time t
-
max_n
()[ソース]¶ Returns the maximum index of Pauli matrices in the Term. If there's no Pauli matrices, returns -1.
-
is_identity
¶ If self is I, returns True, otherwise False.
-
n_qubits
¶ Returns the number of qubits of the term. If the term is constant with identity matrix, n_qubits is 0.
-
static
-
blueqat.pauli.
commutator
(expr1, expr2)[ソース]¶ Returns [expr1, expr2] = expr1 * expr2 - expr2 * expr1.
- Args:
- expr1 (Expr, Term or Pauli operator): Pauli's expression.expr2 (Expr, Term or Pauli operator): Pauli's expression.
- Returns:
- Expr: expr1 * expr2 - expr2 * expr1.
-
blueqat.pauli.
is_commutable
(expr1, expr2, eps=1e-08)[ソース]¶ Test whether expr1 and expr2 are commutable.
- Args:
- expr1 (Expr, Term or Pauli operator): Pauli's expression.expr2 (Expr, Term or Pauli operator): Pauli's expression.eps (float, optional): Machine epsilon. If | [expr1, expr2 ]| < eps, consider it is commutable.
- Returns:
- bool: if expr1 and expr2 are commutable, returns True, otherwise False.
-
blueqat.pauli.
pauli_from_char
(ch, n=0)[ソース]¶ Make Pauli matrix from an character.
- Args:
- ch (str): "X" or "Y" or "Z" or "I".n (int, optional): Make Pauli matrix as n-th qubits.
- Returns:
- If ch is "X" => X, "Y" => Y, "Z" => Z, "I" => I
- Raises:
- ValueError: When ch is not "X", "Y", "Z" nor "I".
-
blueqat.pauli.
qubo_bit
(n)[ソース]¶ Represent QUBO's bit to Pauli operator of Ising model.
- Args:
- n (int): n-th bit in QUBO
- Returns:
- Expr: Pauli expression of QUBO bit.
-
blueqat.pauli.
term_from_chars
(chars)[ソース]¶ Make Pauli's Term from chars which is written by "X", "Y", "Z" or "I". e.g. "XZIY" => X(3) * Z(2) * Y(0)
- Args:
- chars (str): Written in "X", "Y", "Z" or "I".
- Returns:
- Term: A Term object.
- Raises:
- ValueError: When chars conteins the character which is "X", "Y", "Z" nor "I".
blueqat.vqe module¶
-
class
blueqat.vqe.
AnsatzBase
(hamiltonian, n_params)[ソース]¶ ベースクラス:
object
-
class
blueqat.vqe.
QaoaAnsatz
(hamiltonian, step=1, init_circuit=None, mixer=None)[ソース]¶ ベースクラス:
blueqat.vqe.AnsatzBase
Ansatz for QAOA.
-
class
blueqat.vqe.
Vqe
(ansatz, minimizer=None, sampler=None)[ソース]¶ ベースクラス:
object
-
result
¶ Vqe.result is deprecated. Use result = Vqe.run().
-
-
class
blueqat.vqe.
VqeResult
(vqe=None, params=None, circuit=None)[ソース]¶ ベースクラス:
object
-
probs
¶ Get probabilities. This property is obsoleted. Use get_probs().
-
-
blueqat.vqe.
get_measurement_sampler
(n_sample, run_options=None)[ソース]¶ Returns a function which get the expectations by sampling the measured circuit
-
blueqat.vqe.
get_qiskit_sampler
(backend, **execute_kwargs)[ソース]¶ Returns a function which get the expectation by sampling via Qiskit.
This function requires qiskit module.
blueqat.wq module¶
-
class
blueqat.wq.
Opt
[ソース]¶ ベースクラス:
object
Optimizer for SA/SQA.
-
run
(shots=1, sampler='normal', targetT=0.02, verbose=False)[ソース]¶ Run SA with provided QUBO. Set qubo attribute in advance of calling this method.
-
E
= None¶ List of energies
-
Gf
= None¶ Final strength of transverse magnetic field. [SQA]
-
Gs
= None¶ Initial strength of transverse magnetic field. [SQA]
-
R
= None¶ Descreasing rate of temperature [SA]
-
RBMvisible
= None¶ RBM Models
-
Tf
= None¶ Final temperature [SA]. Temperature [SQA]
-
Ts
= None¶ Initial temperature [SA]
-
ite
= None¶ Iterations [SA]
-
qubo
= None¶ QUBO
-
tro
= None¶ Trotter slices [SQA]
-
-
blueqat.wq.
diag
(diag_ele)[ソース]¶ Create QUBO with diag from list
print(wq.diag([1,2,1])) #=> [[1 0 0] [0 2 0] [0 0 1]]
-
blueqat.wq.
make_qs
(n, m=None)[ソース]¶ Make sympy symbols q0, q1, ...
- Args:
- n(int), m(int, optional):
- If specified both n and m, returns [qn, q(n+1), ..., qm],Only n is specified, returns[q0, q1, ..., qn].
- Return:
- tuple(Symbol): Tuple of sympy symbols.
-
blueqat.wq.
nbody_separation
(expr, qs)[ソース]¶ Convert n-body problem to 2-body problem.
- Args:
- expr: sympy expressions to be separated.qs: sympy's symbols to be used as supplementary variable.
- Return:
- new_expr(sympy expr), constraints(sympy expr), mapping(dict(str, str -> Symbol)):
- new_expr is converted problem, constraints is constraints for supplementary variable.You may use expr = new_expr + delta * constraints, delta is floating point variable.mapping is supplementary variable's mapping.
-
blueqat.wq.
net
(narr, nnet)[ソース]¶ Automatically create QUBO which has value 1 for all connectivity defined by array of edges and graph size N
print(wq.net([[0,1],[1,2]],4)) #=> [[0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.]]
this create 4*4 QUBO and put value 1 on connection between 0th and 1st qubit, 1st and 2nd qubit
-
blueqat.wq.
qn_to_qubo
(expr)[ソース]¶ Convert Sympy's expr to QUBO.
- Args:
- expr: Sympy's quadratic expression with variable q0, q1, ...
- Returns:
- [[float]]: Returns QUBO matrix.
-
blueqat.wq.
rands
(rands_ele)[ソース]¶ Create QUBO with random number
print(wq.rands(2)) #=> [[0.89903411 0.68839641] [0. 0.28554602]]
-
blueqat.wq.
sel
(selN, selK, selarr=[])[ソース]¶ Automatically create QUBO which select K qubits from N qubits
print(wq.sel(5,2)) #=> [[-3 2 2 2 2] [ 0 -3 2 2 2] [ 0 0 -3 2 2] [ 0 0 0 -3 2] [ 0 0 0 0 -3]]
if you set array on the 3rd params, the result likely to choose the nth qubit in the array
print(wq.sel(5,2,[0,2])) #=> [[-3.5 2. 2. 2. 2. ] [ 0. -3. 2. 2. 2. ] [ 0. 0. -3.5 2. 2. ] [ 0. 0. 0. -3. 2. ] [ 0. 0. 0. 0. -3. ]]
Module contents¶
-
class
blueqat.
Circuit
(n_qubits=0, ops=None)[ソース]¶ ベースクラス:
object
Store the gate operations and call the backends.
-
copy
(copy_backends=True, copy_default_backend=True, copy_cache=None, copy_history=None)[ソース]¶ Copy the circuit.
- params:
- copy_backends :bool copy backends if True.copy_default_backend :bool copy default_backend if True.
-
dagger
(ignore_measurement=False, copy_backends=False, copy_default_backend=True)[ソース]¶ Make Hermitian conjugate of the circuit.
This feature is beta. Interface may be changed.
- ignore_measurement (bool, optional):
- If True, ignore the measurement in the circuit.Otherwise, if measurement in the circuit, raises ValueError.
-
get_default_backend_name
()[ソース]¶ Get the default backend of this circuit or global setting.
- Returns:
- str: The name of default backend.
-
make_cache
(backend=None)[ソース]¶ Make a cache to reduce the time of run. Some backends may implemented it.
This is temporary API. It may changed or deprecated.
-
run
(*args, backend=None, **kwargs)[ソース]¶ Run the circuit.
Circuit have several backends. When backend parameter is specified, use specified backend, and otherwise, default backend is used. Other parameters are passed to the backend.
The meaning of parameters are depends on the backend specifications. However, following parameters are commonly used.
- Commonly used args (Depends on backend):
- shots (int, optional): The number of sampling the circuit.returns (str, optional): The category of returns value.e.g. "statevector" returns the state vector after run the circuit."shots" returns the counter of measured value.token, url (str, optional): The token and URL for cloud resource.
- Returns:
- Depends on backend.
- Raises:
- Depends on backend.
-
set_default_backend
(backend_name)[ソース]¶ Set the default backend of this circuit.
This setting is only applied for this circuit. If you want to change the default backend of all gates, use BlueqatGlobalSetting.set_default_backend().
After set the default backend by this method, global setting is ignored even if BlueqatGlobalSetting.set_default_backend() is called. If you want to use global default setting, call this method with backend_name=None.
- Args:
- backend_name (str or None): new default backend name.If None is given, global setting is applied.
- Raises:
- ValueError: If backend_name is not registered backend.
-
-
class
blueqat.
BlueqatGlobalSetting
[ソース]¶ ベースクラス:
object
Setting for Blueqat.
-
static
get_default_backend_name
()[ソース]¶ Get the default backend name.
- Returns:
- str: The name of default backend.
-
static
register_backend
(name, backend, allow_overwrite=False)[ソース]¶ Register new backend.
- Args:
- name (str): The name of backend.gateclass (type): The type object of backendallow_overwrite (bool, optional): If True, allow to overwrite the existing backend.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing backend.
- When allow_overwrite=True, this error is not raised.
-
static
register_gate
(name, gateclass, allow_overwrite=False)[ソース]¶ Register new gate to gate set.
- Args:
- name (str): The name of gate.gateclass (type): The type object of gate.allow_overwrite (bool, optional): If True, allow to overwrite the existing gate.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing gate.
- When allow_overwrite=True, this error is not raised.
-
static
register_macro
(name: str, func: Callable, allow_overwrite: bool = False) → None[ソース]¶ Register new macro to Circuit.
- Args:
- name (str): The name of macro.func (callable): The function to be called.allow_overwrite (bool, optional): If True, allow to overwrite the existing macro.Otherwise, raise the ValueError.
- Raises:
- ValueError: The name is duplicated with existing macro, gate or method.
- When allow_overwrite=True, this error is not raised.
-
static
set_default_backend
(name)[ソース]¶ Set the default backend to be used by Circuit. Args:
name (str): The name of the default backend.- Raises:
- ValueError: Specified backend is not registered.
-
static
unregister_backend
(name)[ソース]¶ Unregister a backend.
- Args:
- name (str): The name of the backend to be unregistered.
- Raises:
- ValueError: Specified backend is not registered.
-
static