Skip to content

Commit

Permalink
regen
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Nov 1, 2024
1 parent e356f10 commit 762c77e
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 6 deletions.
62 changes: 61 additions & 1 deletion doc/python_api_reference_vDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4050,7 +4050,7 @@ def __init__(
stim.CircuitInstruction('CX', [stim.target_rec(-1), stim.GateTarget(5)], [])
>>> print(stim.CircuitInstruction('I', [2], tag='100ns'))
I[200ns] 2
I[100ns] 2
"""
```

Expand Down Expand Up @@ -4172,6 +4172,13 @@ def tag(
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit("H[test] 0")[0].tag
'test'
>>> stim.Circuit("H 0")[0].tag
''
"""
```

Expand Down Expand Up @@ -4451,6 +4458,23 @@ def tag(
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit('''
... REPEAT[test] 5 {
... H 0
... }
... ''')[0].tag
'test'
>>> stim.Circuit('''
... REPEAT 5 {
... H 0
... }
... ''')[0].tag
''
"""
```

Expand Down Expand Up @@ -6196,6 +6220,18 @@ def __init__(
coords: List[float],
) -> None:
"""Creates a stim.DemTargetWithCoords.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0]
stim.DemTargetWithCoords(dem_target=stim.DemTarget('D0'), coords=[2, 3])
"""
```

Expand All @@ -6211,6 +6247,18 @@ def coords(
"""Returns the associated coordinate information as a list of floats.
If there is no coordinate information, returns an empty list.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].coords
[2.0, 3.0]
"""
```

Expand All @@ -6224,6 +6272,18 @@ def dem_target(
self,
) -> stim.DemTarget:
"""Returns the actual DEM target as a `stim.DemTarget`.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].dem_target
stim.DemTarget('D0')
"""
```

Expand Down
62 changes: 61 additions & 1 deletion doc/stim.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ class CircuitInstruction:
stim.CircuitInstruction('CX', [stim.target_rec(-1), stim.GateTarget(5)], [])
>>> print(stim.CircuitInstruction('I', [2], tag='100ns'))
I[200ns] 2
I[100ns] 2
"""
def __ne__(
self,
Expand Down Expand Up @@ -3222,6 +3222,13 @@ class CircuitInstruction:
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit("H[test] 0")[0].tag
'test'
>>> stim.Circuit("H 0")[0].tag
''
"""
def target_groups(
self,
Expand Down Expand Up @@ -3417,6 +3424,23 @@ class CircuitRepeatBlock:
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit('''
... REPEAT[test] 5 {
... H 0
... }
... ''')[0].tag
'test'
>>> stim.Circuit('''
... REPEAT 5 {
... H 0
... }
... ''')[0].tag
''
"""
class CircuitTargetsInsideInstruction:
"""Describes a range of targets within a circuit instruction.
Expand Down Expand Up @@ -4812,6 +4836,18 @@ class DemTargetWithCoords:
coords: List[float],
) -> None:
"""Creates a stim.DemTargetWithCoords.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0]
stim.DemTargetWithCoords(dem_target=stim.DemTarget('D0'), coords=[2, 3])
"""
@property
def coords(
Expand All @@ -4820,12 +4856,36 @@ class DemTargetWithCoords:
"""Returns the associated coordinate information as a list of floats.
If there is no coordinate information, returns an empty list.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].coords
[2.0, 3.0]
"""
@property
def dem_target(
self,
) -> stim.DemTarget:
"""Returns the actual DEM target as a `stim.DemTarget`.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].dem_target
stim.DemTarget('D0')
"""
class DetectorErrorModel:
"""An error model built out of independent error mechanics.
Expand Down
62 changes: 61 additions & 1 deletion glue/python/src/stim/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ class CircuitInstruction:
stim.CircuitInstruction('CX', [stim.target_rec(-1), stim.GateTarget(5)], [])
>>> print(stim.CircuitInstruction('I', [2], tag='100ns'))
I[200ns] 2
I[100ns] 2
"""
def __ne__(
self,
Expand Down Expand Up @@ -3222,6 +3222,13 @@ class CircuitInstruction:
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit("H[test] 0")[0].tag
'test'
>>> stim.Circuit("H 0")[0].tag
''
"""
def target_groups(
self,
Expand Down Expand Up @@ -3417,6 +3424,23 @@ class CircuitRepeatBlock:
The tag is an arbitrary string.
The default tag, when none is specified, is the empty string.
Examples:
>>> import stim
>>> stim.Circuit('''
... REPEAT[test] 5 {
... H 0
... }
... ''')[0].tag
'test'
>>> stim.Circuit('''
... REPEAT 5 {
... H 0
... }
... ''')[0].tag
''
"""
class CircuitTargetsInsideInstruction:
"""Describes a range of targets within a circuit instruction.
Expand Down Expand Up @@ -4812,6 +4836,18 @@ class DemTargetWithCoords:
coords: List[float],
) -> None:
"""Creates a stim.DemTargetWithCoords.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0]
stim.DemTargetWithCoords(dem_target=stim.DemTarget('D0'), coords=[2, 3])
"""
@property
def coords(
Expand All @@ -4820,12 +4856,36 @@ class DemTargetWithCoords:
"""Returns the associated coordinate information as a list of floats.
If there is no coordinate information, returns an empty list.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].coords
[2.0, 3.0]
"""
@property
def dem_target(
self,
) -> stim.DemTarget:
"""Returns the actual DEM target as a `stim.DemTarget`.
Examples:
>>> import stim
>>> err = stim.Circuit('''
... R 0 1
... X_ERROR(0.25) 0 1
... M 0 1
... DETECTOR(2, 3) rec[-1] rec[-2]
... OBSERVABLE_INCLUDE(0) rec[-1]
... ''').shortest_graphlike_error()
>>> err[0].dem_error_terms[0].dem_target
stim.DemTarget('D0')
"""
class DetectorErrorModel:
"""An error model built out of independent error mechanics.
Expand Down
6 changes: 3 additions & 3 deletions src/stim/circuit/circuit_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,9 +2093,9 @@ def test_tag_compile_samplers():
DETECTOR[test4](1, 2) rec[-1]
""")
s = c.compile_detector_sampler()
assert 100 < np.sum(s.sample(shots=1000)) < 400
assert 200 < np.sum(s.sample(shots=1000)) < 600
s = c.compile_sampler()
assert 100 < np.sum(s.sample(shots=1000)) < 400
assert 200 < np.sum(s.sample(shots=1000)) < 600
_ = c.compile_m2d_converter()


Expand All @@ -2106,7 +2106,7 @@ def test_tag_detector_error_model():
M[test3](0.25) 0
DETECTOR[test4](1, 2) rec[-1]
""").detector_error_model()
# TODO: propagate tags
# TODO: propagate tags into detector error model
assert dem == stim.DetectorErrorModel("""
error(0.375) D0
detector(1, 2) D0
Expand Down

0 comments on commit 762c77e

Please sign in to comment.