graphix.command module¶
Data validator command classes.
- class CommandKind(*values)[source]¶
Bases:
EnumTag for command kind.
- N = 1¶
- M = 2¶
- E = 3¶
- C = 4¶
- X = 5¶
- Z = 6¶
- S = 7¶
- T = 8¶
- ApplyNoise = 9¶
- class BaseCommand[source]¶
Bases:
ABC,DataclassReprMixinBase class for pattern command.
- class BaseN(node: int)[source]¶
Bases:
BaseCommandBase preparation command.
Represent a preparation of a node. In graphix package, a preparation is an instance of class
N, with an initial state (defaults toPLUS). The base classBaseNallows users to define new class of preparation commands with different abstractions. For example, in the context of blind computations, the server only knows which node is prepared, and the initial state are given by thegraphix.simulator.PrepareMethodprovided by the client.- Parameters:
node (int) – Index of the qubit to prepare.
- class N(node: int, state: State = <factory>)[source]¶
Bases:
BaseN,_KindCheckerPreparation command.
- Parameters:
- class BaseM(node: int)[source]¶
Bases:
BaseCommandBase measurement command.
Represent a measurement of a node. In graphix package, a measurement is an instance of class
M, with given plane, angles, and domains. The base classBaseMallows users to define new class of measurements with different abstractions. For example, in the context of blind computations, the server only knows which node is measured, and the parameters are given by thegraphix.simulator.MeasureMethodprovided by the client.
- class M(node: int, measurement: Measurement = Measurement.X, s_domain: set[int] = <factory>, t_domain: set[int] = <factory>)[source]¶
Bases:
BaseM,_KindCheckerMeasurement command.
- Parameters:
- measurement: Measurement = Measurement.X¶
- clifford(clifford_gate: Clifford) M[source]¶
Return a new measurement command with a Clifford applied.
- map(f: Callable[[Measurement], Measurement]) M[source]¶
Return a measurement command where the function
fhas been applied to the measurement.- Parameters:
f (Callable[[Measurement], Measurement]) – Function applied to the measurement.
- Returns:
The resulting command.
- Return type:
- class E(nodes: tuple[int, int])[source]¶
Bases:
_KindChecker,BaseCommandEntanglement command between two qubits.
- class C(node: int, clifford: Clifford)[source]¶
Bases:
_KindChecker,BaseCommandLocal Clifford gate command.
- Parameters:
- class X(node: int, domain: set[int] = <factory>)[source]¶
Bases:
_KindChecker,BaseCommandX correction command.
- Parameters:
- class Z(node: int, domain: set[int] = <factory>)[source]¶
Bases:
_KindChecker,BaseCommandZ correction command.
- Parameters:
- class S(node: int, domain: set[int] = <factory>)[source]¶
Bases:
_KindChecker,BaseCommandS command.
- Parameters:
- class T[source]¶
Bases:
_KindChecker,BaseCommandT command.
- Parameters:
None – The T command acts globally without parameters.
- class Command[source]¶
Bases:
objectGrouping of all commands for namespace exposure.
Notes
This class is not meant to be instantiated, but rather serves as a namespace for all command types. The type alias for “any command” is
CommandKind.- class N(node: int, state: State = <factory>)¶
Bases:
BaseN,_KindCheckerPreparation command.
- Parameters:
- class M(node: int, measurement: Measurement = Measurement.X, s_domain: set[int] = <factory>, t_domain: set[int] = <factory>)¶
Bases:
BaseM,_KindCheckerMeasurement command.
- Parameters:
- __init__(node: int, measurement: Measurement = Measurement.X, s_domain: set[int] = <factory>, t_domain: set[int] = <factory>) None¶
- map(f: Callable[[Measurement], Measurement]) M¶
Return a measurement command where the function
fhas been applied to the measurement.- Parameters:
f (Callable[[Measurement], Measurement]) – Function applied to the measurement.
- Returns:
The resulting command.
- Return type:
- measurement: Measurement = Measurement.X¶
- class E(nodes: tuple[int, int])¶
Bases:
_KindChecker,BaseCommandEntanglement command between two qubits.
- class C(node: int, clifford: Clifford)¶
Bases:
_KindChecker,BaseCommandLocal Clifford gate command.
- Parameters:
- class X(node: int, domain: set[int] = <factory>)¶
Bases:
_KindChecker,BaseCommandX correction command.
- Parameters:
- class Z(node: int, domain: set[int] = <factory>)¶
Bases:
_KindChecker,BaseCommandZ correction command.
- Parameters:
- class S(node: int, domain: set[int] = <factory>)¶
Bases:
_KindChecker,BaseCommandS command.
- Parameters:
- class T¶
Bases:
_KindChecker,BaseCommandT command.
- Parameters:
None – The T command acts globally without parameters.