@@ -67,6 +67,7 @@ API references for stable versions are kept on the [stim github wiki](https://gi
67
67
- [`stim.CircuitErrorLocation.flipped_measurement`](#stim.CircuitErrorLocation.flipped_measurement)
68
68
- [`stim.CircuitErrorLocation.flipped_pauli_product`](#stim.CircuitErrorLocation.flipped_pauli_product)
69
69
- [`stim.CircuitErrorLocation.instruction_targets`](#stim.CircuitErrorLocation.instruction_targets)
70
+ - [`stim.CircuitErrorLocation.noise_tag`](#stim.CircuitErrorLocation.noise_tag)
70
71
- [`stim.CircuitErrorLocation.stack_frames`](#stim.CircuitErrorLocation.stack_frames)
71
72
- [`stim.CircuitErrorLocation.tick_offset`](#stim.CircuitErrorLocation.tick_offset)
72
73
- [`stim.CircuitErrorLocationStackFrame`](#stim.CircuitErrorLocationStackFrame)
@@ -100,6 +101,7 @@ API references for stable versions are kept on the [stim github wiki](https://gi
100
101
- [`stim.CircuitTargetsInsideInstruction.__init__`](#stim.CircuitTargetsInsideInstruction.__init__)
101
102
- [`stim.CircuitTargetsInsideInstruction.args`](#stim.CircuitTargetsInsideInstruction.args)
102
103
- [`stim.CircuitTargetsInsideInstruction.gate`](#stim.CircuitTargetsInsideInstruction.gate)
104
+ - [`stim.CircuitTargetsInsideInstruction.tag`](#stim.CircuitTargetsInsideInstruction.tag)
103
105
- [`stim.CircuitTargetsInsideInstruction.target_range_end`](#stim.CircuitTargetsInsideInstruction.target_range_end)
104
106
- [`stim.CircuitTargetsInsideInstruction.target_range_start`](#stim.CircuitTargetsInsideInstruction.target_range_start)
105
107
- [`stim.CircuitTargetsInsideInstruction.targets_in_range`](#stim.CircuitTargetsInsideInstruction.targets_in_range)
@@ -128,6 +130,7 @@ API references for stable versions are kept on the [stim github wiki](https://gi
128
130
- [`stim.DemInstruction.__repr__`](#stim.DemInstruction.__repr__)
129
131
- [`stim.DemInstruction.__str__`](#stim.DemInstruction.__str__)
130
132
- [`stim.DemInstruction.args_copy`](#stim.DemInstruction.args_copy)
133
+ - [`stim.DemInstruction.tag`](#stim.DemInstruction.tag)
131
134
- [`stim.DemInstruction.target_groups`](#stim.DemInstruction.target_groups)
132
135
- [`stim.DemInstruction.targets_copy`](#stim.DemInstruction.targets_copy)
133
136
- [`stim.DemInstruction.type`](#stim.DemInstruction.type)
@@ -3627,6 +3630,7 @@ def __init__(
3627
3630
flipped_measurement: object,
3628
3631
instruction_targets: stim.CircuitTargetsInsideInstruction,
3629
3632
stack_frames: List[stim.CircuitErrorLocationStackFrame],
3633
+ noise_tag: str = '',
3630
3634
) -> None:
3631
3635
"""Creates a stim.CircuitErrorLocation.
3632
3636
@@ -3661,9 +3665,11 @@ def __init__(
3661
3665
... instruction_repetitions_arg=0,
3662
3666
... ),
3663
3667
... ),
3668
+ ... noise_tag='test-tag',
3664
3669
... )
3665
3670
>>> print(err)
3666
3671
CircuitErrorLocation {
3672
+ noise_tag: test-tag
3667
3673
flipped_pauli_product: X0
3668
3674
Circuit location stack trace:
3669
3675
(after 1 TICKs)
@@ -3762,6 +3768,30 @@ def instruction_targets(
3762
3768
"""
3763
3769
```
3764
3770
3771
+ <a name="stim.CircuitErrorLocation.noise_tag"></a>
3772
+ ```python
3773
+ # stim.CircuitErrorLocation.noise_tag
3774
+
3775
+ # (in class stim.CircuitErrorLocation)
3776
+ @property
3777
+ def noise_tag(
3778
+ self,
3779
+ ) -> str:
3780
+ """The tag on the noise instruction that caused the error.
3781
+
3782
+ Examples:
3783
+ >>> import stim
3784
+ >>> err = stim.Circuit('''
3785
+ ... R 0
3786
+ ... Y_ERROR[test-tag](0.125) 0
3787
+ ... M 0
3788
+ ... OBSERVABLE_INCLUDE(0) rec[-1]
3789
+ ... ''').shortest_graphlike_error()
3790
+ >>> err[0].circuit_error_locations[0].noise_tag
3791
+ 'test-tag'
3792
+ """
3793
+ ```
3794
+
3765
3795
<a name="stim.CircuitErrorLocation.stack_frames"></a>
3766
3796
```python
3767
3797
# stim.CircuitErrorLocation.stack_frames
@@ -4515,6 +4545,7 @@ def __init__(
4515
4545
self,
4516
4546
*,
4517
4547
gate: str,
4548
+ tag: str = '',
4518
4549
args: List[float],
4519
4550
target_range_start: int,
4520
4551
target_range_end: int,
@@ -4526,6 +4557,7 @@ def __init__(
4526
4557
>>> import stim
4527
4558
>>> val = stim.CircuitTargetsInsideInstruction(
4528
4559
... gate='X_ERROR',
4560
+ ... tag='',
4529
4561
... args=[0.25],
4530
4562
... target_range_start=0,
4531
4563
... target_range_end=1,
@@ -4586,6 +4618,32 @@ def gate(
4586
4618
"""
4587
4619
```
4588
4620
4621
+ <a name="stim.CircuitTargetsInsideInstruction.tag"></a>
4622
+ ```python
4623
+ # stim.CircuitTargetsInsideInstruction.tag
4624
+
4625
+ # (in class stim.CircuitTargetsInsideInstruction)
4626
+ @property
4627
+ def tag(
4628
+ self,
4629
+ ) -> str:
4630
+ """Returns the tag of the gate / instruction that was being executed.
4631
+
4632
+ Examples:
4633
+ >>> import stim
4634
+ >>> err = stim.Circuit('''
4635
+ ... R 0 1
4636
+ ... X_ERROR[look-at-me-imma-tag](0.25) 0 1
4637
+ ... M 0 1
4638
+ ... DETECTOR(2, 3) rec[-1] rec[-2]
4639
+ ... OBSERVABLE_INCLUDE(0) rec[-1]
4640
+ ... ''').shortest_graphlike_error()
4641
+ >>> loc: stim.CircuitErrorLocation = err[0].circuit_error_locations[0]
4642
+ >>> loc.instruction_targets.tag
4643
+ 'look-at-me-imma-tag'
4644
+ """
4645
+ ```
4646
+
4589
4647
<a name="stim.CircuitTargetsInsideInstruction.target_range_end"></a>
4590
4648
```python
4591
4649
# stim.CircuitTargetsInsideInstruction.target_range_end
@@ -5693,6 +5751,8 @@ def __init__(
5693
5751
type: str,
5694
5752
args: Optional[Iterable[float]] = None,
5695
5753
targets: Optional[Iterable[stim.DemTarget]] = None,
5754
+ *,
5755
+ tag: str = "",
5696
5756
) -> None:
5697
5757
"""Creates or parses a stim.DemInstruction.
5698
5758
@@ -5704,15 +5764,18 @@ def __init__(
5704
5764
"error(0.1)").
5705
5765
targets: The objects the instruction involves (e.g. the "D0" and "L1" in
5706
5766
"error(0.1) D0 L1").
5767
+ tag: An arbitrary piece of text attached to the instruction.
5707
5768
5708
5769
Examples:
5709
5770
>>> import stim
5710
5771
>>> instruction = stim.DemInstruction(
5711
5772
... 'error',
5712
5773
... [0.125],
5713
- ... [stim.target_relative_detector_id(5)])
5774
+ ... [stim.target_relative_detector_id(5)],
5775
+ ... tag='test-tag',
5776
+ ... )
5714
5777
>>> print(instruction)
5715
- error(0.125) D5
5778
+ error[test-tag] (0.125) D5
5716
5779
5717
5780
>>> print(stim.DemInstruction('error(0.125) D5 L6 ^ D4 # comment'))
5718
5781
error(0.125) D5 L6 ^ D4
@@ -5785,6 +5848,30 @@ def args_copy(
5785
5848
"""
5786
5849
```
5787
5850
5851
+ <a name="stim.DemInstruction.tag"></a>
5852
+ ```python
5853
+ # stim.DemInstruction.tag
5854
+
5855
+ # (in class stim.DemInstruction)
5856
+ @property
5857
+ def tag(
5858
+ self,
5859
+ ) -> str:
5860
+ """Returns the arbitrary text tag attached to the instruction.
5861
+
5862
+ Examples:
5863
+ >>> import stim
5864
+ >>> dem = stim.DetectorErrorModel('''
5865
+ ... error[test-tag](0.125) D0
5866
+ ... error(0.125) D0
5867
+ ... ''')
5868
+ >>> dem[0].tag
5869
+ 'test-tag'
5870
+ >>> dem[1].tag
5871
+ ''
5872
+ """
5873
+ ```
5874
+
5788
5875
<a name="stim.DemInstruction.target_groups"></a>
5789
5876
```python
5790
5877
# stim.DemInstruction.target_groups
@@ -6795,18 +6882,21 @@ def append(
6795
6882
instruction: object,
6796
6883
parens_arguments: object = None,
6797
6884
targets: List[object] = (),
6885
+ *,
6886
+ tag: str = '',
6798
6887
) -> None:
6799
6888
"""Appends an instruction to the detector error model.
6800
6889
6801
6890
Args:
6802
6891
instruction: Either the name of an instruction, a stim.DemInstruction, or a
6803
- stim.DemRepeatBlock. The `parens_arguments` and `targets` arguments are
6804
- given if and only if the instruction is a name.
6892
+ stim.DemRepeatBlock. The `parens_arguments`, `targets`, and 'tag'
6893
+ arguments should be given if and only if the instruction is a name.
6805
6894
parens_arguments: Numeric values parameterizing the instruction. The numbers
6806
6895
inside parentheses in a detector error model file (eg. the `0.25` in
6807
6896
`error(0.25) D0`). This argument can be given either a list of doubles,
6808
6897
or a single double (which will be implicitly wrapped into a list).
6809
6898
targets: The instruction targets, such as the `D0` in `error(0.25) D0`.
6899
+ tag: An arbitrary piece of text attached to the repeat instruction.
6810
6900
6811
6901
Examples:
6812
6902
>>> import stim
@@ -6819,18 +6909,18 @@ def append(
6819
6909
... stim.DemTarget.separator(),
6820
6910
... stim.DemTarget.relative_detector_id(2),
6821
6911
... stim.DemTarget.logical_observable_id(3),
6822
- ... ])
6912
+ ... ], tag='test-tag' )
6823
6913
>>> print(repr(m))
6824
6914
stim.DetectorErrorModel('''
6825
6915
error(0.125) D1
6826
- error(0.25) D1 ^ D2 L3
6916
+ error[test-tag] (0.25) D1 ^ D2 L3
6827
6917
''')
6828
6918
6829
6919
>>> m.append("shift_detectors", (1, 2, 3), [5])
6830
6920
>>> print(repr(m))
6831
6921
stim.DetectorErrorModel('''
6832
6922
error(0.125) D1
6833
- error(0.25) D1 ^ D2 L3
6923
+ error[test-tag] (0.25) D1 ^ D2 L3
6834
6924
shift_detectors(1, 2, 3) 5
6835
6925
''')
6836
6926
@@ -6840,17 +6930,17 @@ def append(
6840
6930
>>> print(repr(m))
6841
6931
stim.DetectorErrorModel('''
6842
6932
error(0.125) D1
6843
- error(0.25) D1 ^ D2 L3
6933
+ error[test-tag] (0.25) D1 ^ D2 L3
6844
6934
shift_detectors(1, 2, 3) 5
6845
6935
repeat 3 {
6846
6936
error(0.125) D1
6847
- error(0.25) D1 ^ D2 L3
6937
+ error[test-tag] (0.25) D1 ^ D2 L3
6848
6938
shift_detectors(1, 2, 3) 5
6849
6939
}
6850
6940
error(0.125) D1
6851
6941
repeat 3 {
6852
6942
error(0.125) D1
6853
- error(0.25) D1 ^ D2 L3
6943
+ error[test-tag] (0.25) D1 ^ D2 L3
6854
6944
shift_detectors(1, 2, 3) 5
6855
6945
}
6856
6946
''')
0 commit comments