From 762c77eec39909d74b71fb1b26d2459ca63990c8 Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Thu, 31 Oct 2024 20:24:27 -0700 Subject: [PATCH] regen --- doc/python_api_reference_vDev.md | 62 ++++++++++++++++++++++++- doc/stim.pyi | 62 ++++++++++++++++++++++++- glue/python/src/stim/__init__.pyi | 62 ++++++++++++++++++++++++- src/stim/circuit/circuit_pybind_test.py | 6 +-- 4 files changed, 186 insertions(+), 6 deletions(-) diff --git a/doc/python_api_reference_vDev.md b/doc/python_api_reference_vDev.md index 9d75076d..d33e4840 100644 --- a/doc/python_api_reference_vDev.md +++ b/doc/python_api_reference_vDev.md @@ -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 """ ``` @@ -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 + '' """ ``` @@ -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 + '' """ ``` @@ -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]) """ ``` @@ -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] """ ``` @@ -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') """ ``` diff --git a/doc/stim.pyi b/doc/stim.pyi index bace4a99..b9e1c185 100644 --- a/doc/stim.pyi +++ b/doc/stim.pyi @@ -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, @@ -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, @@ -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. @@ -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( @@ -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. diff --git a/glue/python/src/stim/__init__.pyi b/glue/python/src/stim/__init__.pyi index bace4a99..b9e1c185 100644 --- a/glue/python/src/stim/__init__.pyi +++ b/glue/python/src/stim/__init__.pyi @@ -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, @@ -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, @@ -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. @@ -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( @@ -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. diff --git a/src/stim/circuit/circuit_pybind_test.py b/src/stim/circuit/circuit_pybind_test.py index ddafec63..0c612bc1 100644 --- a/src/stim/circuit/circuit_pybind_test.py +++ b/src/stim/circuit/circuit_pybind_test.py @@ -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() @@ -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