jet.GateFactory¶
-
class
GateFactory
[source]¶ Bases:
object
GateFactory is an implementation of the factory design pattern for the Gate class. The create() method constructs a Gate instance from a name that has been registered by a Gate subclass using the @register decorator.
Attributes
Map that associates names with concrete Gate subclasses.
-
registry
: Dict[str, type] = {'BS': <class 'jet.gate.Beamsplitter'>, 'Beamsplitter': <class 'jet.gate.Beamsplitter'>, 'CNOT': <class 'jet.gate.CX'>, 'CPhaseShift': <class 'jet.gate.CPhaseShift'>, 'CRX': <class 'jet.gate.CRX'>, 'CRY': <class 'jet.gate.CRY'>, 'CRZ': <class 'jet.gate.CRZ'>, 'CRot': <class 'jet.gate.CRot'>, 'CSWAP': <class 'jet.gate.CSWAP'>, 'CX': <class 'jet.gate.CX'>, 'CY': <class 'jet.gate.CY'>, 'CZ': <class 'jet.gate.CZ'>, 'D': <class 'jet.gate.Displacement'>, 'Displacement': <class 'jet.gate.Displacement'>, 'H': <class 'jet.gate.Hadamard'>, 'Hadamard': <class 'jet.gate.Hadamard'>, 'ISWAP': <class 'jet.gate.ISWAP'>, 'NOT': <class 'jet.gate.PauliX'>, 'PauliX': <class 'jet.gate.PauliX'>, 'PauliY': <class 'jet.gate.PauliY'>, 'PauliZ': <class 'jet.gate.PauliZ'>, 'PhaseShift': <class 'jet.gate.PhaseShift'>, 'RX': <class 'jet.gate.RX'>, 'RY': <class 'jet.gate.RY'>, 'RZ': <class 'jet.gate.RZ'>, 'Rot': <class 'jet.gate.Rot'>, 'S': <class 'jet.gate.S'>, 'SWAP': <class 'jet.gate.SWAP'>, 'SX': <class 'jet.gate.SX'>, 'Squeezing': <class 'jet.gate.Squeezing'>, 'T': <class 'jet.gate.T'>, 'Toffoli': <class 'jet.gate.Toffoli'>, 'TwoModeSqueezing': <class 'jet.gate.TwoModeSqueezing'>, 'U1': <class 'jet.gate.U1'>, 'U2': <class 'jet.gate.U2'>, 'U3': <class 'jet.gate.U3'>, 'X': <class 'jet.gate.PauliX'>, 'Y': <class 'jet.gate.PauliY'>, 'Z': <class 'jet.gate.PauliZ'>, 'beamsplitter': <class 'jet.gate.Beamsplitter'>, 'bs': <class 'jet.gate.Beamsplitter'>, 'cnot': <class 'jet.gate.CX'>, 'cphaseshift': <class 'jet.gate.CPhaseShift'>, 'crot': <class 'jet.gate.CRot'>, 'crx': <class 'jet.gate.CRX'>, 'cry': <class 'jet.gate.CRY'>, 'crz': <class 'jet.gate.CRZ'>, 'cswap': <class 'jet.gate.CSWAP'>, 'cx': <class 'jet.gate.CX'>, 'cy': <class 'jet.gate.CY'>, 'cz': <class 'jet.gate.CZ'>, 'd': <class 'jet.gate.Displacement'>, 'displacement': <class 'jet.gate.Displacement'>, 'h': <class 'jet.gate.Hadamard'>, 'hadamard': <class 'jet.gate.Hadamard'>, 'iswap': <class 'jet.gate.ISWAP'>, 'not': <class 'jet.gate.PauliX'>, 'paulix': <class 'jet.gate.PauliX'>, 'pauliy': <class 'jet.gate.PauliY'>, 'pauliz': <class 'jet.gate.PauliZ'>, 'phaseshift': <class 'jet.gate.PhaseShift'>, 'rot': <class 'jet.gate.Rot'>, 'rx': <class 'jet.gate.RX'>, 'ry': <class 'jet.gate.RY'>, 'rz': <class 'jet.gate.RZ'>, 's': <class 'jet.gate.S'>, 'squeezing': <class 'jet.gate.Squeezing'>, 'swap': <class 'jet.gate.SWAP'>, 'sx': <class 'jet.gate.SX'>, 't': <class 'jet.gate.T'>, 'toffoli': <class 'jet.gate.Toffoli'>, 'twomodesqueezing': <class 'jet.gate.TwoModeSqueezing'>, 'u1': <class 'jet.gate.U1'>, 'u2': <class 'jet.gate.U2'>, 'u3': <class 'jet.gate.U3'>, 'x': <class 'jet.gate.PauliX'>, 'y': <class 'jet.gate.PauliY'>, 'z': <class 'jet.gate.PauliZ'>}¶ Map that associates names with concrete Gate subclasses.
Methods
create
(name, *params[, adjoint, scalar])Constructs a gate by name.
register
(names)Registers a set of names with a class type.
unregister
(cls)Unregisters a class type.
-
static
create
(name: str, *params: float, adjoint: bool = False, scalar: float = 1, **kwargs) → jet.gate.Gate[source]¶ Constructs a gate by name.
- Raises
KeyError – If there is no entry for the given name in the registry.
- Parameters
name (str) – Registered name of the desired gate.
params (float) – Parameters to pass to the gate constructor.
adjoint (bool) – Whether to take the adjoint of the gate.
scalar (float) – Scaling factor to apply to the gate.
kwargs – Keyword arguments to pass to the gate constructor.
- Returns
The constructed gate.
- Return type
-