diff --git a/graphix/command.py b/graphix/command.py index 000ba20e..82ca917b 100644 --- a/graphix/command.py +++ b/graphix/command.py @@ -64,7 +64,22 @@ class N(_KindChecker, DataclassReprMixin): @dataclasses.dataclass(repr=False) -class M(_KindChecker, DataclassReprMixin): +class BaseM(DataclassReprMixin): + """Base measurement command. + + Represent a measurement of a node. In `graphix`, a measurement is an instance of + class `M`, with given plane, angles, and domains. The base class `BaseM` allows 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 the :class:`graphix.simulator.MeasureMethod` provided by the client. + """ + + node: Node + kind: ClassVar[Literal[CommandKind.M]] = dataclasses.field(default=CommandKind.M, init=False) + + +@dataclasses.dataclass(repr=False) +class M(BaseM, _KindChecker): r"""Measurement command. Parameters @@ -81,7 +96,6 @@ class M(_KindChecker, DataclassReprMixin): Domain for the Z byproduct operator. """ - node: Node plane: Plane = Plane.XY angle: ExpressionOrFloat = 0.0 s_domain: set[Node] = dataclasses.field(default_factory=set) @@ -214,8 +228,6 @@ class T(_KindChecker): Command = Union[N, M, E, C, X, Z, S, T] Correction = Union[X, Z] -BaseM = M - @dataclasses.dataclass class MeasureUpdate: