stimflow 1.17.dev0__tar.gz → 1.17.dev1780910265__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/PKG-INFO +1 -1
  2. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/setup.py +1 -1
  3. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/__init__.py +1 -1
  4. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_builder.py +70 -14
  5. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_compiler.py +122 -1
  6. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_circuit_html.py +7 -3
  7. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow.egg-info/PKG-INFO +1 -1
  8. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/README.md +0 -0
  9. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/requirements.txt +0 -0
  10. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/setup.cfg +0 -0
  11. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/__init__.py +0 -0
  12. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk.py +0 -0
  13. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_builder_test.py +0 -0
  14. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_compiler_test.py +0 -0
  15. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_interface.py +0 -0
  16. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_loop.py +0 -0
  17. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_reflow.py +0 -0
  18. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_reflow_test.py +0 -0
  19. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_chunk_test.py +0 -0
  20. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_code_util.py +0 -0
  21. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_code_util_test.py +0 -0
  22. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_flow_metadata.py +0 -0
  23. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_flow_util.py +0 -0
  24. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_flow_util_test.py +0 -0
  25. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_patch.py +0 -0
  26. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_patch_test.py +0 -0
  27. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_stabilizer_code.py +0 -0
  28. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_stabilizer_code_test.py +0 -0
  29. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_test_util.py +0 -0
  30. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_weave.py +0 -0
  31. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_chunk/_weave_test.py +0 -0
  32. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/__init__.py +0 -0
  33. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_circuit_util.py +0 -0
  34. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_circuit_util_test.py +0 -0
  35. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_complex_util.py +0 -0
  36. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_complex_util_test.py +0 -0
  37. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_flow.py +0 -0
  38. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_flow_test.py +0 -0
  39. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_noise.py +0 -0
  40. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_noise_test.py +0 -0
  41. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_pauli_map.py +0 -0
  42. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_pauli_map_test.py +0 -0
  43. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_str_html.py +0 -0
  44. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_str_svg.py +0 -0
  45. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_tile.py +0 -0
  46. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_core/_tile_test.py +0 -0
  47. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/__init__.py +0 -0
  48. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_data.py +0 -0
  49. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_data_test.py +0 -0
  50. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer.py +0 -0
  51. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_circuit.py +0 -0
  52. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_circuit_test.py +0 -0
  53. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_det_obs_annotation.py +0 -0
  54. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_empty.py +0 -0
  55. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_feedback.py +0 -0
  56. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_feedback_test.py +0 -0
  57. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_interact.py +0 -0
  58. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_interact_swap.py +0 -0
  59. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_interact_swap_test.py +0 -0
  60. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_iswap.py +0 -0
  61. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_loop.py +0 -0
  62. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_measure.py +0 -0
  63. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_mpp.py +0 -0
  64. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_noise.py +0 -0
  65. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_qubit_coord_annotation.py +0 -0
  66. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_reset.py +0 -0
  67. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_rotation.py +0 -0
  68. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_rotation_test.py +0 -0
  69. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_shift_coord_annotation.py +0 -0
  70. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_sqrt_pp.py +0 -0
  71. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_swap.py +0 -0
  72. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_tag.py +0 -0
  73. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_layer_tag_test.py +0 -0
  74. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_transpile.py +0 -0
  75. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_layers/_transpile_test.py +0 -0
  76. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_3d_model.py +0 -0
  77. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_3d_model_test.py +0 -0
  78. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_3d_model_text_texture.py +0 -0
  79. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_3d_model_viewer.py +0 -0
  80. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/__init__.py +0 -0
  81. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_circuit_html_test.py +0 -0
  82. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_circuit_layer_svg.py +0 -0
  83. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_html.py +0 -0
  84. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_patch_svg.py +0 -0
  85. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_patch_svg_test.py +0 -0
  86. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow/_viz/_viz_svg.py +0 -0
  87. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow.egg-info/SOURCES.txt +0 -0
  88. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow.egg-info/dependency_links.txt +0 -0
  89. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow.egg-info/requires.txt +0 -0
  90. {stimflow-1.17.dev0 → stimflow-1.17.dev1780910265}/src/stimflow.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stimflow
3
- Version: 1.17.dev0
3
+ Version: 1.17.dev1780910265
4
4
  Summary: A library for creating quantum error correction circuits.
5
5
  Home-page: https://github.com/quantumlib/stim
6
6
  Author: Craig Gidney
@@ -19,7 +19,7 @@ with open('README.md', encoding='UTF-8') as f:
19
19
  with open('requirements.txt', encoding='UTF-8') as f:
20
20
  requirements = f.read().splitlines()
21
21
 
22
- __version__ = '1.17.dev0'
22
+ __version__ = '1.17.dev1780910265'
23
23
 
24
24
  setup(
25
25
  name='stimflow',
@@ -1,4 +1,4 @@
1
- __version__ = '1.17.dev0'
1
+ __version__ = '1.17.dev1780910265'
2
2
 
3
3
  from stimflow._chunk import (
4
4
  Chunk,
@@ -397,19 +397,29 @@ class ChunkBuilder:
397
397
  ) -> None:
398
398
  """Declares that the circuit being built should have a given stabilizer flow.
399
399
 
400
- When chunks are concatenated, their flows are paired up in order to form detectors.
400
+ When chunks are concatenated, their flows are matched up in order to form detectors.
401
+ At most one of `start`, `end`, and `measurements` can be set to "auto" in order to
402
+ infer it.
401
403
 
402
404
  Args:
403
405
  start: Defaults to None (empty). The stabilizer that the flow starts as, at the
404
406
  beginning of the circuit. If the flow begins within the circuit, this should
405
- be set to None or an empty PauliMap.
407
+ be set to None or an empty PauliMap. If this is set to "auto", it will be
408
+ inferred by backpropagation from `end` and `measurements`.
406
409
  end: Defaults to None (empty). The stabilizer that the flow ends as, at the
407
410
  end of the circuit. If the flow ends within the circuit, this should
408
- be set to None or an empty PauliMap.
411
+ be set to None or an empty PauliMap. If this is set to "auto", it will be
412
+ inferred by forward propagating from `start` and measurements` (no resets will
413
+ be included in the forward propagation).
409
414
  measurements: Defaults to empty. The keys identifying measurements mediate the flow.
410
415
  For example, if a stabilizer is measured by a circuit then this would
411
416
  typically be a singleton list containing the measurement that reveals
412
- the stabilizer's value.
417
+ the stabilizer's value. If this is set to "auto", it will be inferred from
418
+ `start` and `end` by Gaussian elimination via `stim.Circuit.flow_generators`.
419
+
420
+ Caution: beware using "auto" when the solution isn't unique (e.g. this is
421
+ common if the circuit includes multiple rounds of stabilizer measurement), as
422
+ it may select a solution you don't expect.
413
423
  ignore_unknown_measurements: Defaults to False. When set to False, unrecognized measurement
414
424
  ids cause the method to raise an exception instead of adding the flow. When set
415
425
  to True, unrecognized measurements are silently discarded.
@@ -428,22 +438,68 @@ class ChunkBuilder:
428
438
  Examples:
429
439
  >>> import stimflow as sf
430
440
  >>> builder = sf.ChunkBuilder()
431
- >>> builder.append('R', [0])
432
- >>> builder.append('MX', [1j])
433
- >>> builder.append('TICK')
434
- >>> builder.append('CX', [(1j, 0)])
435
441
 
436
- >>> builder.add_flow(end=sf.PauliMap.from_xs([0, 1j]), measurements=[1j])
437
- >>> builder.add_flow(end=sf.PauliMap.from_zs([0, 1j]))
438
- >>> builder.add_flow(start=sf.PauliMap.from_xs([1j]), measurements=[1j])
442
+ >>> # 0 ───────@─────────── 0
443
+ >>> # │
444
+ >>> # 1 ───R───X───X───M─── 1
445
+ >>> # │
446
+ >>> # 2 ───────────@─────── 2
447
+ >>> builder.append('R', [1])
448
+ >>> builder.append('TICK')
449
+ >>> builder.append('CX', [(0, 1)])
450
+ >>> builder.append('TICK')
451
+ >>> builder.append('CX', [(2, 1)])
452
+ >>> builder.append('TICK')
453
+ >>> builder.append('M', [1])
454
+
455
+ >>> # 0 z━━━━━━━@─────────── 0
456
+ >>> # ┃
457
+ >>> # 1 ───R━━━X━━━X━━[M]── 1
458
+ >>> # ┃
459
+ >>> # 2 z━━━━━━━━━━━@─────── 2
460
+ >>> builder.add_flow(
461
+ ... start=sf.PauliMap({0: 'Z', 2: 'Z'}),
462
+ ... measurements=[1],
463
+ ... )
464
+
465
+ >>> # 0 ───────@━━━━━━━━━━━z 0
466
+ >>> # ┃
467
+ >>> # 1 ───R━━━X━━━X━━[M]── 1
468
+ >>> # ┃
469
+ >>> # 2 ───────────@━━━━━━━z 2
470
+ >>> builder.add_flow(
471
+ ... measurements=[1],
472
+ ... end=sf.PauliMap({0: 'Z', 2: 'Z'}),
473
+ ... )
474
+
475
+ >>> # 0 x═══════@═══════════x 0
476
+ >>> # ║
477
+ >>> # 1 ───R───X═══X───M─── 1
478
+ >>> # ║
479
+ >>> # 2 x═══════════@═══════x 2
480
+ >>> builder.add_flow(
481
+ ... start=sf.PauliMap({0: 'X', 2: 'X'}),
482
+ ... end=sf.PauliMap({0: 'X', 2: 'X'}),
483
+ ... )
484
+
485
+ >>> # 0 z━━━━━━━@─────────── 0
486
+ >>> # ┃
487
+ >>> # 1 ───R━━━X━━━X━━[M]── 1
488
+ >>> # ┃
489
+ >>> # 2 ───────────@━━━━━━━z 2
490
+ >>> builder.add_flow(
491
+ ... start=sf.PauliMap({0: 'Z'}),
492
+ ... measurements=[1],
493
+ ... end=sf.PauliMap({2: 'Z'}),
494
+ ... )
439
495
 
440
496
  >>> builder.finish_chunk().verify()
441
497
  """
442
498
  auto_count = (start == "auto") + (end == "auto") + (measurements == "auto")
443
499
  if auto_count > 1:
444
- raise ValueError("Only one of `start`, `end`, and `ms` can be set to auto.\n"
445
- f" {start=}"
446
- f" {measurements=}"
500
+ raise ValueError("Only one of `start`, `end`, and `measurements` can be set to 'auto'.\n"
501
+ f" {start=}\n"
502
+ f" {measurements=}\n"
447
503
  f" {end=}")
448
504
  if isinstance(start, PauliMap):
449
505
  obs_name = start.obs_name
@@ -18,7 +18,68 @@ if TYPE_CHECKING:
18
18
 
19
19
 
20
20
  class ChunkCompiler:
21
- """Compiles appended chunks into a unified circuit."""
21
+ """Compiles appended chunks into a unified circuit.
22
+
23
+ Examples:
24
+ >>> import stim
25
+ >>> import stimflow as sf
26
+
27
+ >>> zz = sf.PauliMap({0: 'Z', 1 + 1j: 'Z'})
28
+ >>> idle_chunk = sf.Chunk(
29
+ ... stim.Circuit('''
30
+ ... QUBIT_COORDS(0, 0) 0
31
+ ... QUBIT_COORDS(0, 1) 1
32
+ ... QUBIT_COORDS(1, 1) 2
33
+ ... R 1
34
+ ... TICK
35
+ ... CX 0 1
36
+ ... TICK
37
+ ... CX 2 1
38
+ ... TICK
39
+ ... M 1
40
+ ... '''),
41
+ ... flows=[
42
+ ... sf.Flow(start=zz, measurement_indices=[0]),
43
+ ... sf.Flow(end=zz, measurement_indices=[0]),
44
+ ... ]
45
+ ... )
46
+
47
+ >>> compiler = sf.ChunkCompiler()
48
+ >>> compiler.append_magic_init_chunk()
49
+ >>> compiler.append(idle_chunk)
50
+ >>> compiler.append(idle_chunk)
51
+ >>> compiler.append_magic_end_chunk()
52
+ >>> compiler.finish_circuit()
53
+ stim.Circuit('''
54
+ QUBIT_COORDS(0, 0) 0
55
+ QUBIT_COORDS(0, 1) 1
56
+ QUBIT_COORDS(1, 1) 2
57
+ MPP Z0*Z2
58
+ TICK
59
+ R 1
60
+ TICK
61
+ CX 0 1
62
+ TICK
63
+ CX 2 1
64
+ TICK
65
+ M 1
66
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
67
+ SHIFT_COORDS(0, 0, 1)
68
+ TICK
69
+ R 1
70
+ TICK
71
+ CX 0 1
72
+ TICK
73
+ CX 2 1
74
+ TICK
75
+ M 1
76
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
77
+ SHIFT_COORDS(0, 0, 1)
78
+ TICK
79
+ MPP Z0*Z2
80
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
81
+ ''')
82
+ """
22
83
 
23
84
  def __init__(self, *, metadata_func: Callable[[Flow], FlowMetadata] | None = None):
24
85
  """
@@ -26,6 +87,66 @@ class ChunkCompiler:
26
87
  Args:
27
88
  metadata_func: Determines coordinate data appended to detectors
28
89
  (after x, y, and t). Defaults to None (no extra metadata).
90
+
91
+ Examples:
92
+ >>> import stim
93
+ >>> import stimflow as sf
94
+
95
+ >>> zz = sf.PauliMap({0: 'Z', 1 + 1j: 'Z'})
96
+ >>> idle_chunk = sf.Chunk(
97
+ ... stim.Circuit('''
98
+ ... QUBIT_COORDS(0, 0) 0
99
+ ... QUBIT_COORDS(0, 1) 1
100
+ ... QUBIT_COORDS(1, 1) 2
101
+ ... R 1
102
+ ... TICK
103
+ ... CX 0 1
104
+ ... TICK
105
+ ... CX 2 1
106
+ ... TICK
107
+ ... M 1
108
+ ... '''),
109
+ ... flows=[
110
+ ... sf.Flow(start=zz, measurement_indices=[0]),
111
+ ... sf.Flow(end=zz, measurement_indices=[0]),
112
+ ... ]
113
+ ... )
114
+
115
+ >>> compiler = sf.ChunkCompiler()
116
+ >>> compiler.append_magic_init_chunk()
117
+ >>> compiler.append(idle_chunk)
118
+ >>> compiler.append(idle_chunk)
119
+ >>> compiler.append_magic_end_chunk()
120
+ >>> compiler.finish_circuit()
121
+ stim.Circuit('''
122
+ QUBIT_COORDS(0, 0) 0
123
+ QUBIT_COORDS(0, 1) 1
124
+ QUBIT_COORDS(1, 1) 2
125
+ MPP Z0*Z2
126
+ TICK
127
+ R 1
128
+ TICK
129
+ CX 0 1
130
+ TICK
131
+ CX 2 1
132
+ TICK
133
+ M 1
134
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
135
+ SHIFT_COORDS(0, 0, 1)
136
+ TICK
137
+ R 1
138
+ TICK
139
+ CX 0 1
140
+ TICK
141
+ CX 2 1
142
+ TICK
143
+ M 1
144
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
145
+ SHIFT_COORDS(0, 0, 1)
146
+ TICK
147
+ MPP Z0*Z2
148
+ DETECTOR(0.5, 0.5, 0) rec[-2] rec[-1]
149
+ ''')
29
150
  """
30
151
  if metadata_func is None:
31
152
  metadata_func = lambda _: FlowMetadata()
@@ -985,8 +985,9 @@ def _stim_circuit_html_viewer(
985
985
  escaped = escaped.replace(", ", ",").replace(" ", "_")
986
986
  escaped = escaped.replace("QUBIT_COORDS", "Q")
987
987
  escaped = escaped.replace("DETECTOR", "DT")
988
- escaped = escaped.replace("(", "%28").replace(")", "%29")
989
- escaped = escaped.replace("[", "%5B").replace("]", "%5D")
988
+ for c in "%()[]&?#/=@ &<>\"'\\":
989
+ c_esc = '%' + hex(ord(c))[2:].rjust(2, '0').upper()
990
+ escaped = escaped.replace(c, c_esc)
990
991
  local_server_crumble_url = f"""https://algassert.com/crumble#circuit={escaped}"""
991
992
 
992
993
  from stimflow._core import str_html
@@ -1005,7 +1006,7 @@ def _stim_circuit_html_viewer(
1005
1006
  <button id="btnNext">Next Layer (hotkey: e)</button>
1006
1007
  <a id="crumble-link" href="{local_server_crumble_url}">Open in Crumble</a>
1007
1008
  <div id="viewer"
1008
- style="border: 1px solid black; margin-bottom: 50px; width: 100%; height: 90vh;
1009
+ style="border: 1px solid black; margin-bottom: 50px; width: 100%; height: 500px;
1009
1010
  resize: both; overflow: auto" tabindex="1" autofocus
1010
1011
  >"""
1011
1012
  + all_svg_image_tags
@@ -1028,6 +1029,9 @@ def _stim_circuit_html_viewer(
1028
1029
  }
1029
1030
  let layers = [];
1030
1031
  let container = document.getElementById("circuit-viewer-container");
1032
+ if (window.self === window.top) {
1033
+ container.querySelector("#viewer").style.height = "90vh";
1034
+ }
1031
1035
  container.id = 'circuit-viewer-container-do-not-find-again';
1032
1036
  while (true) {
1033
1037
  let svg = container.querySelector('#layer' + layers.length);
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stimflow
3
- Version: 1.17.dev0
3
+ Version: 1.17.dev1780910265
4
4
  Summary: A library for creating quantum error correction circuits.
5
5
  Home-page: https://github.com/quantumlib/stim
6
6
  Author: Craig Gidney