From e2963493eb08c3ec761bbd5eeea461757606e663 Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Wed, 1 Oct 2025 17:41:26 +0200 Subject: [PATCH] Revert `BaseM` removed in #205 This reverts the removal of `BaseM`, which was deleted in commit a07197ae2097403ae0b2d62108b46ef7659a4331. This commit subsumes #237, which restores `BaseM` but lacks the associated documentation Currently, `BaseM` is a type alias for `M`, which is not particularly useful. However, `BaseM` is used in Veriphix in blind patterns: the server only knows which node is measured, and the measurement itself is specified by the client's `MeasureMethod`. This commit is a step towards upstreaming Graphix's features needed for Veriphix (and for UBQC in general). --- graphix/command.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/graphix/command.py b/graphix/command.py index 000ba20e..3e0294f4 100644 --- a/graphix/command.py +++ b/graphix/command.py @@ -64,7 +64,21 @@ 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 MBQC, a measure is an instance of `M`, + with given plane, angles, and domains. 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 +95,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 +227,6 @@ class T(_KindChecker): Command = Union[N, M, E, C, X, Z, S, T] Correction = Union[X, Z] -BaseM = M - @dataclasses.dataclass class MeasureUpdate: