Skip to content

Commit 94dce47

Browse files
authored
Add observable slicing support to detslice diagrams (#475)
- Fix sinter not throttling print output - Add simplified names for diagrams - Added ability to filter by DemTarget in detslice diagrams, e.g. D5 or L0 - Added stim::CoordFilter helper class
1 parent f9e05ed commit 94dce47

25 files changed

Lines changed: 2634 additions & 839 deletions

doc/python_api_reference_vDev.md

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,86 +1243,79 @@ def diagram(
12431243
def diagram(
12441244
self,
12451245
*,
1246-
type: 'Literal["timeline-3d"]',
1246+
type: 'Literal["timeline-3d", "timeline-3d-html"]',
12471247
) -> 'stim._DiagramHelper':
12481248
pass
12491249
@overload
12501250
def diagram(
12511251
self,
12521252
*,
1253-
type: 'Literal["timeline-3d-html"]',
1253+
type: 'Literal["matchgraph-svg"]',
12541254
) -> 'stim._DiagramHelper':
12551255
pass
12561256
@overload
12571257
def diagram(
12581258
self,
12591259
*,
1260-
type: 'Literal["match-graph-svg"]',
1260+
type: 'Literal["matchgraph-3d"]',
12611261
) -> 'stim._DiagramHelper':
12621262
pass
12631263
@overload
12641264
def diagram(
12651265
self,
12661266
*,
1267-
type: 'Literal["match-graph-3d"]',
1267+
type: 'Literal["matchgraph-3d-html"]',
12681268
) -> 'stim._DiagramHelper':
12691269
pass
12701270
@overload
12711271
def diagram(
12721272
self,
12731273
*,
1274-
type: 'Literal["match-graph-3d-html"]',
1275-
) -> 'stim._DiagramHelper':
1276-
pass
1277-
@overload
1278-
def diagram(
1279-
self,
1280-
*,
1281-
type: 'Literal["detector-slice-text"]',
1274+
type: 'Literal["detslice-text"]',
12821275
tick: int,
1283-
filter_coords: Optional[Iterable[Iterable[float]]] = None,
1276+
filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),),
12841277
) -> 'stim._DiagramHelper':
12851278
pass
12861279
@overload
12871280
def diagram(
12881281
self,
12891282
*,
1290-
type: 'Literal["detector-slice-svg"]',
1283+
type: 'Literal["detslice-svg"]',
12911284
tick: Union[int, range],
1292-
filter_coords: Optional[Iterable[Iterable[float]]] = None,
1285+
filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),),
12931286
) -> 'stim._DiagramHelper':
12941287
pass
12951288
@overload
12961289
def diagram(
12971290
self,
12981291
*,
1299-
type: 'Literal["time-slice-svg"]',
1292+
type: 'Literal["detslice-with-ops-svg"]',
13001293
tick: Union[int, range],
1301-
filter_coords: Optional[Iterable[Iterable[float]]] = None,
1294+
filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),),
13021295
) -> 'stim._DiagramHelper':
13031296
pass
13041297
@overload
13051298
def diagram(
13061299
self,
13071300
*,
1308-
type: 'Literal["time+detector-slice-svg"]',
1301+
type: 'Literal["timeslice-svg"]',
13091302
tick: Union[int, range],
1310-
filter_coords: Optional[Iterable[Iterable[float]]] = None,
1303+
filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),),
13111304
) -> 'stim._DiagramHelper':
13121305
pass
13131306
@overload
13141307
def diagram(
13151308
self,
13161309
*,
1317-
type: 'Literal["interactive"]',
1310+
type: 'Literal["interactive", "interactive-html"]',
13181311
) -> 'stim._DiagramHelper':
13191312
pass
13201313
def diagram(
13211314
self,
13221315
type: str = 'timeline-text',
13231316
*,
13241317
tick: Union[None, int, range] = None,
1325-
filter_coords: Optional[Iterable[Iterable[float]]] = None,
1318+
filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),),
13261319
) -> 'stim._DiagramHelper':
13271320
"""Returns a diagram of the circuit, from a variety of options.
13281321
@@ -1342,11 +1335,11 @@ def diagram(
13421335
"timeline-3d-html": Same 3d model as 'timeline-3d' but
13431336
embedded into an HTML web page containing an interactive
13441337
THREE.js viewer for the 3d model.
1345-
"detector-slice-text": An ASCII diagram of the stabilizers
1338+
"detslice-text": An ASCII diagram of the stabilizers
13461339
that detectors declared by the circuit correspond to
13471340
during the TICK instruction identified by the `tick`
13481341
argument.
1349-
"detector-slice-svg": An SVG image of the stabilizers
1342+
"detslice-svg": An SVG image of the stabilizers
13501343
that detectors declared by the circuit correspond to
13511344
during the TICK instruction identified by the `tick`
13521345
argument. For example, a detector slice diagram of a
@@ -1355,24 +1348,24 @@ def diagram(
13551348
usual diagram of a surface code.
13561349
13571350
Uses the Pauli color convention XYZ=RGB.
1358-
"match-graph-svg": An SVG image of the match graph extracted
1351+
"matchgraph-svg": An SVG image of the match graph extracted
13591352
from the circuit by stim.Circuit.detector_error_model.
1360-
"match-graph-3d": An 3D model of the match graph extracted
1353+
"matchgraph-3d": An 3D model of the match graph extracted
13611354
from the circuit by stim.Circuit.detector_error_model.
1362-
"match-graph-3d-html": Same 3d model as 'match-graph-3d' but
1355+
"matchgraph-3d-html": Same 3d model as 'match-graph-3d' but
13631356
embedded into an HTML web page containing an interactive
13641357
THREE.js viewer for the 3d model.
1365-
"time-slice-svg": An SVG image of the operations applied
1358+
"timeslice-svg": An SVG image of the operations applied
13661359
between two TICK instructions in the circuit, with the
13671360
operations laid out in 2d.
1368-
"time+detector-slice-svg": A combination of time-slice-svg
1369-
and detector-slice-svg, with the operations overlaid
1361+
"detslice-with-ops-svg": A combination of timeslice-svg
1362+
and detslice-svg, with the operations overlaid
13701363
over the detector slices taken from the TICK after the
13711364
operations were applied.
1372-
"interactive": An HTML web page containing Crumble (an
1373-
interactive editor for 2D stabilizer circuits)
1374-
initialized with the given circuit as its default
1375-
contents.
1365+
"interactive" or "interactive-html": An HTML web page
1366+
containing Crumble (an interactive editor for 2D
1367+
stabilizer circuits) initialized with the given circuit
1368+
as its default contents.
13761369
tick: Required for detector and time slice diagrams. Specifies
13771370
which TICK instruction, or range of TICK instructions, to
13781371
slice at. Note that the first TICK instruction in the
@@ -1384,9 +1377,11 @@ def diagram(
13841377
13851378
Passing `range(A, B)` for a time slice will show the
13861379
operations between tick A and tick B.
1387-
filter_coords: A set of acceptable coordinate prefixes. For
1388-
detector slice diagrams, only detectors whose coordinates
1389-
begin with one of these filters will be included.
1380+
filter_coords: A set of acceptable coordinate prefixes, or
1381+
desired stim.DemTargets. For detector slice diagrams, only
1382+
detectors match one of the filters are included. If no filter
1383+
is specified, all detectors are included (but no observables).
1384+
To include an observable, add it as one of the filters.
13901385
13911386
Returns:
13921387
An object whose `__str__` method returns the diagram, so that
@@ -1417,7 +1412,7 @@ def diagram(
14171412
... DETECTOR rec[-1] rec[-2]
14181413
... ''')
14191414
1420-
>>> print(circuit.diagram("detector-slice-text", tick=1))
1415+
>>> print(circuit.diagram("detslice-text", tick=1))
14211416
q0: -Z:D0-
14221417
|
14231418
q1: -Z:D0-
@@ -4957,19 +4952,19 @@ def copy(
49574952
@overload
49584953
def diagram(
49594954
self,
4960-
type: 'Literal["match-graph-svg"]',
4955+
type: 'Literal["matchgraph-svg"]',
49614956
) -> 'stim._DiagramHelper':
49624957
pass
49634958
@overload
49644959
def diagram(
49654960
self,
4966-
type: 'Literal["match-graph-3d"]',
4961+
type: 'Literal["matchgraph-3d"]',
49674962
) -> 'stim._DiagramHelper':
49684963
pass
49694964
@overload
49704965
def diagram(
49714966
self,
4972-
type: 'Literal["match-graph-3d-html"]',
4967+
type: 'Literal["matchgraph-3d-html"]',
49734968
) -> 'stim._DiagramHelper':
49744969
pass
49754970
def diagram(
@@ -4980,11 +4975,11 @@ def diagram(
49804975
49814976
Args:
49824977
type: The type of diagram. Available types are:
4983-
"match-graph-svg": An image of the decoding graph of the
4978+
"matchgraph-svg": An image of the decoding graph of the
49844979
detector error model. Red lines are errors crossing a
49854980
logical observable. Blue lines are undecomposed hyper
49864981
errors.
4987-
"match-graph-3d": A 3d model of the decoding graph of the
4982+
"matchgraph-3d": A 3d model of the decoding graph of the
49884983
detector error model. Red lines are errors crossing a
49894984
logical observable. Blue lines are undecomposed hyper
49904985
errors.
@@ -4993,7 +4988,7 @@ def diagram(
49934988
opened online in viewers such as
49944989
https://gltf-viewer.donmccurdy.com/ . Red lines are
49954990
errors crossing a logical observable.
4996-
"match-graph-3d-html": Same 3d model as 'match-graph-3d' but
4991+
"matchgraph-3d-html": Same 3d model as 'match-graph-3d' but
49974992
embedded into an HTML web page containing an interactive
49984993
THREE.js viewer for the 3d model.
49994994

0 commit comments

Comments
 (0)