From 96ddc5f7d79f6627453ce1ceb1c66184784128fb Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 01:28:32 +0000 Subject: [PATCH 01/10] Clarify documentation for OBSERVABLE_INCLUDE. --- src/stim/gates/gate_data_annotations.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/stim/gates/gate_data_annotations.cc b/src/stim/gates/gate_data_annotations.cc index ddf18f11a..dbcaa62f6 100644 --- a/src/stim/gates/gate_data_annotations.cc +++ b/src/stim/gates/gate_data_annotations.cc @@ -137,13 +137,19 @@ detection event simulations and affect whether the observable is included in err makes it easier to benchmark all observables of a code, without having to introduce noiseless qubits entangled with the logical qubit to avoid the testing of the X observable anticommuting with the testing of the Z observable. +Unlike a `DETECTOR` instruction which provides a complete description of a detector by listing all its constituent +measurement records, an individual `OBSERVABLE_INCLUDE` instruction is not required to (and generally does not) fully +describe a logical observable. Instead, measurement records or Pauli targets are added to it incrementally. A logical +observable can be given both types of description: as a collection of Pauli targets and as a collection of measurement +record targets. + Parens Arguments: A non-negative integer specifying the index of the logical observable to add the measurement records to. Targets: - The measurement records to add to the specified observable. + The measurement records or Pauli terms to add to the specified observable. Example: @@ -178,6 +184,12 @@ Parens Arguments: DETECTOR rec[-3] rec[-6] OBSERVABLE_INCLUDE(0) X0 X1 OBSERVABLE_INCLUDE(1) Z0 Z2 + + # Stim circuit may include a description of an observable in terms of Pauli targets + # alongside a description in terms of measurement records. + OBSERVABLE_INCLUDE(0) Z0 Z1 + M 0 1 + OBSERVABLE_INCLUDE(0) rec[-2] rec[-1] )MARKDOWN", .unitary_data = {}, .flow_data = {}, From 4fd89ead93e92bec8e441c5bdb91e4ab3bfe069a Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 04:36:28 +0000 Subject: [PATCH 02/10] Update doc/gates.md --- doc/gates.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/gates.md b/doc/gates.md index 3978e320a..4f21ce09e 100644 --- a/doc/gates.md +++ b/doc/gates.md @@ -4879,13 +4879,19 @@ detection event simulations and affect whether the observable is included in err makes it easier to benchmark all observables of a code, without having to introduce noiseless qubits entangled with the logical qubit to avoid the testing of the X observable anticommuting with the testing of the Z observable. +Unlike a `DETECTOR` instruction which provides a complete description of a detector by listing all its constituent +measurement records, an individual `OBSERVABLE_INCLUDE` instruction is not required to (and generally does not) fully +describe a logical observable. Instead, measurement records or Pauli targets are added to it incrementally. A logical +observable can be given both types of description: as a collection of Pauli targets and as a collection of measurement +record targets. + Parens Arguments: A non-negative integer specifying the index of the logical observable to add the measurement records to. Targets: - The measurement records to add to the specified observable. + The measurement records or Pauli terms to add to the specified observable. Example: @@ -4921,6 +4927,12 @@ Example: OBSERVABLE_INCLUDE(0) X0 X1 OBSERVABLE_INCLUDE(1) Z0 Z2 + # Stim circuit may include a description of an observable in terms of Pauli targets + # alongside a description in terms of measurement records. + OBSERVABLE_INCLUDE(0) Z0 Z1 + M 0 1 + OBSERVABLE_INCLUDE(0) rec[-2] rec[-1] + ### The 'QUBIT_COORDS' Instruction From fff1cde78c943d08951732a1b55ebe21f3495e93 Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 06:03:16 +0000 Subject: [PATCH 03/10] ./dev/regen_docs.sh --- doc/sinter_api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sinter_api.md b/doc/sinter_api.md index 5cb64f821..a29c5b19c 100644 --- a/doc/sinter_api.md +++ b/doc/sinter_api.md @@ -852,7 +852,7 @@ def to_csv_line( >>> print(sinter.CSV_HEADER) shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts >>> print(stat.to_csv_line()) - 22, 3, 0, 5.00,pymatching,test,"{""a"":[1,2,3]}", + 22, 3, 0, 5,pymatching,test,"{""a"":[1,2,3]}", """ ``` From 70c2c6b244d50a4bc2b5e400c3d756219ea0f8e9 Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 06:26:36 +0000 Subject: [PATCH 04/10] Skip __annotate_func__ --- dev/util_gen_stub_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/util_gen_stub_file.py b/dev/util_gen_stub_file.py index bcc6193a7..ae4452690 100644 --- a/dev/util_gen_stub_file.py +++ b/dev/util_gen_stub_file.py @@ -36,6 +36,7 @@ "__next__", } skip = { + "__annotate_func__", "__firstlineno__", "__static_attributes__", "__replace__", From fd8a83e20b860b68036e2c59a9a4913769def783 Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 06:33:02 +0000 Subject: [PATCH 05/10] __annotations_cache__ --- dev/util_gen_stub_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/util_gen_stub_file.py b/dev/util_gen_stub_file.py index ae4452690..6e66646a1 100644 --- a/dev/util_gen_stub_file.py +++ b/dev/util_gen_stub_file.py @@ -37,6 +37,7 @@ } skip = { "__annotate_func__", + "__annotations_cache__", "__firstlineno__", "__static_attributes__", "__replace__", From ec911a2c93388244769c74192b829d51f56aaf84 Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Sat, 6 Dec 2025 06:45:06 +0000 Subject: [PATCH 06/10] Placate diff --- doc/sinter_api.md | 128 +++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/doc/sinter_api.md b/doc/sinter_api.md index a29c5b19c..b8eb87d8a 100644 --- a/doc/sinter_api.md +++ b/doc/sinter_api.md @@ -161,11 +161,11 @@ class CollectionOptions: biggest batch size that can finish in under the given number of seconds. Limits each batch to be no larger than that. """ - max_shots: Optional[int] = None - max_errors: Optional[int] = None - start_batch_size: Optional[int] = None - max_batch_size: Optional[int] = None - max_batch_seconds: Optional[float] = None + max_shots: Union = None + max_errors: Union = None + start_batch_size: Union = None + max_batch_size: Union = None + max_batch_seconds: Union = None ``` @@ -461,9 +461,9 @@ class Fit: of the best fit's square error, or whose likelihood was within some maximum Bayes factor of the max likelihood hypothesis. """ - low: Optional[float] - best: Optional[float] - high: Optional[float] + low: Union + best: Union + high: Union ``` @@ -586,16 +586,16 @@ class Task: def __init__( self, *, - circuit: Optional[stim.Circuit] = None, - decoder: Optional[str] = None, - detector_error_model: Optional[stim.DetectorErrorModel] = None, - postselection_mask: Optional[np.ndarray] = None, - postselected_observables_mask: Optional[np.ndarray] = None, + circuit: stim.Circuit | None = None, + decoder: str | None = None, + detector_error_model: stim.DetectorErrorModel | None = None, + postselection_mask: np.ndarray | None = None, + postselected_observables_mask: np.ndarray | None = None, json_metadata: Any = None, collection_options: sinter.CollectionOptions = sinter.CollectionOptions(), skip_validation: bool = False, - circuit_path: Union[str, pathlib.Path, NoneType] = None, - _unvalidated_strong_id: Optional[str] = None, + circuit_path: str | pathlib.Path | None = None, + _unvalidated_strong_id: str | None = None, ) -> None: """ Args: @@ -852,7 +852,7 @@ def to_csv_line( >>> print(sinter.CSV_HEADER) shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts >>> print(stat.to_csv_line()) - 22, 3, 0, 5,pymatching,test,"{""a"":[1,2,3]}", + 22, 3, 0, 5.00,pymatching,test,"{""a"":[1,2,3]}", """ ``` @@ -864,14 +864,14 @@ def to_csv_line( def with_edits( self, *, - strong_id: Optional[str] = None, - decoder: Optional[str] = None, - json_metadata: Optional[Any] = None, - shots: Optional[int] = None, - errors: Optional[int] = None, - discards: Optional[int] = None, - seconds: Optional[float] = None, - custom_counts: Optional[Counter[str]] = None, + strong_id: str | None = None, + decoder: str | None = None, + json_metadata: Any | None = None, + shots: int | None = None, + errors: int | None = None, + discards: int | None = None, + seconds: float | None = None, + custom_counts: Counter[str] | None = None, ) -> sinter.TaskStats: ``` @@ -925,23 +925,23 @@ def better_sorted_str_terms( def collect( *, num_workers: int, - tasks: Union[Iterator[sinter.Task], Iterable[sinter.Task]], - existing_data_filepaths: Iterable[Union[str, pathlib.Path]] = (), - save_resume_filepath: Union[NoneType, str, pathlib.Path] = None, - progress_callback: Optional[Callable[[sinter.Progress], NoneType]] = None, - max_shots: Optional[int] = None, - max_errors: Optional[int] = None, + tasks: Iterator[sinter.Task] | Iterable[sinter.Task], + existing_data_filepaths: Iterable[str | pathlib.Path] = (), + save_resume_filepath: None | str | pathlib.Path = None, + progress_callback: Callable[[sinter.Progress], NoneType] | None = None, + max_shots: int | None = None, + max_errors: int | None = None, count_observable_error_combos: bool = False, count_detection_events: bool = False, - decoders: Optional[Iterable[str]] = None, - max_batch_seconds: Optional[int] = None, - max_batch_size: Optional[int] = None, - start_batch_size: Optional[int] = None, + decoders: Iterable[str] | None = None, + max_batch_seconds: int | None = None, + max_batch_size: int | None = None, + start_batch_size: int | None = None, print_progress: bool = False, - hint_num_tasks: Optional[int] = None, - custom_decoders: Optional[Dict[str, Union[sinter.Decoder, sinter.Sampler]]] = None, - custom_error_count_key: Optional[str] = None, - allowed_cpu_affinity_ids: Optional[Iterable[int]] = None, + hint_num_tasks: int | None = None, + custom_decoders: Dict[str, sinter.Decoder | sinter.Sampler] | None = None, + custom_error_count_key: str | None = None, + allowed_cpu_affinity_ids: Iterable[int] | None = None, ) -> List[sinter.TaskStats]: """Collects statistics from the given tasks, using multiprocessing. @@ -1252,20 +1252,20 @@ def group_by( def iter_collect( *, num_workers: int, - tasks: Union[Iterator[sinter.Task], Iterable[sinter.Task]], - hint_num_tasks: Optional[int] = None, - additional_existing_data: Union[NoneType, Dict[str, sinter.TaskStats], Iterable[sinter.TaskStats]] = None, - max_shots: Optional[int] = None, - max_errors: Optional[int] = None, - decoders: Optional[Iterable[str]] = None, - max_batch_seconds: Optional[int] = None, - max_batch_size: Optional[int] = None, - start_batch_size: Optional[int] = None, + tasks: Iterator[sinter.Task] | Iterable[sinter.Task], + hint_num_tasks: int | None = None, + additional_existing_data: None | Dict[str, sinter.TaskStats] | Iterable[sinter.TaskStats] = None, + max_shots: int | None = None, + max_errors: int | None = None, + decoders: Iterable[str] | None = None, + max_batch_seconds: int | None = None, + max_batch_size: int | None = None, + start_batch_size: int | None = None, count_observable_error_combos: bool = False, count_detection_events: bool = False, - custom_decoders: Optional[Dict[str, Union[sinter.Decoder, sinter.Sampler]]] = None, - custom_error_count_key: Optional[str] = None, - allowed_cpu_affinity_ids: Optional[Iterable[int]] = None, + custom_decoders: Dict[str, sinter.Decoder | sinter.Sampler] | None = None, + custom_error_count_key: str | None = None, + allowed_cpu_affinity_ids: Iterable[int] | None = None, ) -> Iterator[sinter.Progress]: """Iterates error correction statistics collected from worker processes. @@ -1377,7 +1377,7 @@ def iter_collect( # (at top-level in the sinter module) def log_binomial( *, - p: Union[float, np.ndarray], + p: float | np.ndarray, n: int, hits: int, ) -> np.ndarray: @@ -1466,7 +1466,7 @@ def plot_discard_rate( group_func: Callable[[sinter.TaskStats], ~TCurveId] = lambda _: None, filter_func: Callable[[sinter.TaskStats], Any] = lambda _: True, plot_args_func: Callable[[int, ~TCurveId, List[sinter.TaskStats]], Dict[str, Any]] = lambda index, group_key, group_stats: dict(), - highlight_max_likelihood_factor: Optional[float] = 1000.0, + highlight_max_likelihood_factor: float | None = 1000.0, point_label_func: Callable[[sinter.TaskStats], Any] = lambda _: None, ) -> None: """Plots discard rates in curves with uncertainty highlights. @@ -1530,8 +1530,8 @@ def plot_error_rate( group_func: Callable[[sinter.TaskStats], ~TCurveId] = lambda _: None, filter_func: Callable[[sinter.TaskStats], Any] = lambda _: True, plot_args_func: Callable[[int, ~TCurveId, List[sinter.TaskStats]], Dict[str, Any]] = lambda index, group_key, group_stats: dict(), - highlight_max_likelihood_factor: Optional[float] = 1000.0, - line_fits: Optional[Tuple[Literal['linear', 'log', 'sqrt'], Literal['linear', 'log', 'sqrt']]] = None, + highlight_max_likelihood_factor: float | None = 1000.0, + line_fits: Tuple[Literal['linear', 'log', 'sqrt'], Literal['linear', 'log', 'sqrt']] | None = None, point_label_func: Callable[[sinter.TaskStats], Any] = lambda _: None, ) -> None: """Plots error rates in curves with uncertainty highlights. @@ -1593,7 +1593,7 @@ def plot_error_rate( # (at top-level in the sinter module) def post_selection_mask_from_4th_coord( - dem: Union[stim.Circuit, stim.DetectorErrorModel], + dem: stim.Circuit | stim.DetectorErrorModel, ) -> np.ndarray: """Returns a mask that postselects detector's with non-zero 4th coordinate. @@ -1666,7 +1666,7 @@ def predict_observables( dets: np.ndarray, decoder: str, bit_pack_result: bool = False, - custom_decoders: Optional[Dict[str, sinter.Decoder]] = None, + custom_decoders: Dict[str, sinter.Decoder] | None = None, ) -> np.ndarray: """Predicts which observables were flipped based on detection event data. @@ -1729,7 +1729,7 @@ def predict_observables_bit_packed( dem: stim.DetectorErrorModel, dets_bit_packed: np.ndarray, decoder: str, - custom_decoders: Optional[Dict[str, sinter.Decoder]] = None, + custom_decoders: Dict[str, sinter.Decoder] | None = None, ) -> np.ndarray: """Predicts which observables were flipped based on detection event data. @@ -1786,14 +1786,14 @@ def predict_observables_bit_packed( def predict_on_disk( *, decoder: str, - dem_path: Union[str, pathlib.Path], - dets_path: Union[str, pathlib.Path], + dem_path: str | pathlib.Path, + dets_path: str | pathlib.Path, dets_format: str, - obs_out_path: Union[str, pathlib.Path], + obs_out_path: str | pathlib.Path, obs_out_format: str, postselect_detectors_with_non_zero_4th_coord: bool = False, - discards_out_path: Union[str, pathlib.Path, NoneType] = None, - discards_out_format: Optional[str] = None, + discards_out_path: str | pathlib.Path | None = None, + discards_out_format: str | None = None, custom_decoders: Dict[str, sinter.Decoder] = None, ) -> None: """Performs decoding and postselection on disk. @@ -1866,11 +1866,11 @@ def read_stats_from_csv_files( # (at top-level in the sinter module) def shot_error_rate_to_piece_error_rate( - shot_error_rate: Union[float, sinter.Fit], + shot_error_rate: float | sinter.Fit, *, pieces: float, values: float = 1, -) -> Union[float, sinter.Fit]: +) -> float | sinter.Fit: """Convert from total error rate to per-piece error rate. Args: From eb3781f67744fe1066eaddb570146b8ed3505353 Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Wed, 21 Jan 2026 00:36:32 +0000 Subject: [PATCH 07/10] dev/regen_docs.sh --- doc/gates.md | 2 +- doc/python_api_reference_vDev.md | 802 ++---------------------------- doc/sinter_api.md | 128 ++--- doc/stim.pyi | 626 ++--------------------- glue/python/src/stim/__init__.pyi | 626 ++--------------------- 5 files changed, 173 insertions(+), 2011 deletions(-) diff --git a/doc/gates.md b/doc/gates.md index 7f9825026..4f21ce09e 100644 --- a/doc/gates.md +++ b/doc/gates.md @@ -3579,7 +3579,7 @@ Example: # Sample errors from the distribution 10% XX, 20% YZ, 70% II. # Apply independently to qubit pairs (1,2), (5,6), and (8,3) - PAULI_CHANNEL_2(0,0,0, 0,0.1,0,0, 0,0,0,0.2, 0,0,0,0) 1 2 5 6 8 3 + PAULI_CHANNEL_2(0,0,0, 0.1,0,0,0, 0,0,0,0.2, 0,0,0,0) 1 2 5 6 8 3 Pauli Mixture: diff --git a/doc/python_api_reference_vDev.md b/doc/python_api_reference_vDev.md index 01ce7fe4b..cfef6f0be 100644 --- a/doc/python_api_reference_vDev.md +++ b/doc/python_api_reference_vDev.md @@ -109,28 +109,6 @@ API references for stable versions are kept on the [stim github wiki](https://gi - [`stim.CircuitTargetsInsideInstruction.target_range_end`](#stim.CircuitTargetsInsideInstruction.target_range_end) - [`stim.CircuitTargetsInsideInstruction.target_range_start`](#stim.CircuitTargetsInsideInstruction.target_range_start) - [`stim.CircuitTargetsInsideInstruction.targets_in_range`](#stim.CircuitTargetsInsideInstruction.targets_in_range) -- [`stim.CliffordString`](#stim.CliffordString) - - [`stim.CliffordString.__add__`](#stim.CliffordString.__add__) - - [`stim.CliffordString.__eq__`](#stim.CliffordString.__eq__) - - [`stim.CliffordString.__getitem__`](#stim.CliffordString.__getitem__) - - [`stim.CliffordString.__iadd__`](#stim.CliffordString.__iadd__) - - [`stim.CliffordString.__imul__`](#stim.CliffordString.__imul__) - - [`stim.CliffordString.__init__`](#stim.CliffordString.__init__) - - [`stim.CliffordString.__ipow__`](#stim.CliffordString.__ipow__) - - [`stim.CliffordString.__len__`](#stim.CliffordString.__len__) - - [`stim.CliffordString.__mul__`](#stim.CliffordString.__mul__) - - [`stim.CliffordString.__ne__`](#stim.CliffordString.__ne__) - - [`stim.CliffordString.__pow__`](#stim.CliffordString.__pow__) - - [`stim.CliffordString.__repr__`](#stim.CliffordString.__repr__) - - [`stim.CliffordString.__rmul__`](#stim.CliffordString.__rmul__) - - [`stim.CliffordString.__setitem__`](#stim.CliffordString.__setitem__) - - [`stim.CliffordString.__str__`](#stim.CliffordString.__str__) - - [`stim.CliffordString.all_cliffords_string`](#stim.CliffordString.all_cliffords_string) - - [`stim.CliffordString.copy`](#stim.CliffordString.copy) - - [`stim.CliffordString.random`](#stim.CliffordString.random) - - [`stim.CliffordString.x_outputs`](#stim.CliffordString.x_outputs) - - [`stim.CliffordString.y_outputs`](#stim.CliffordString.y_outputs) - - [`stim.CliffordString.z_outputs`](#stim.CliffordString.z_outputs) - [`stim.CompiledDemSampler`](#stim.CompiledDemSampler) - [`stim.CompiledDemSampler.sample`](#stim.CompiledDemSampler.sample) - [`stim.CompiledDemSampler.sample_write`](#stim.CompiledDemSampler.sample_write) @@ -1686,7 +1664,7 @@ def detector_error_model( # (in class stim.Circuit) def diagram( self, - type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', + type: str = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -5049,714 +5027,6 @@ def targets_in_range( """ ``` - -```python -# stim.CliffordString - -# (at top-level in the stim module) -class CliffordString: - """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). - - Represents a collection of Clifford operations applied pairwise to a - collection of qubits. Ignores global phase. - - Examples: - >>> import stim - >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") - stim.CliffordString("I,C_ZYX,SQRT_X_DAG") - """ -``` - - -```python -# stim.CliffordString.__add__ - -# (in class stim.CliffordString) -def __add__( - self, - rhs: stim.CliffordString, -) -> stim.CliffordString: - """Concatenates two CliffordStrings. - - Args: - rhs: The suffix of the concatenation. - - Returns: - The concatenated Clifford string. - - Examples: - >>> import stim - >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") - stim.CliffordString("I,X,H,Y,S") - """ -``` - - -```python -# stim.CliffordString.__eq__ - -# (in class stim.CliffordString) -def __eq__( - self, - arg0: stim.CliffordString, -) -> bool: - """Determines if two Clifford strings have identical contents. - """ -``` - - -```python -# stim.CliffordString.__getitem__ - -# (in class stim.CliffordString) -@overload -def __getitem__( - self, - index_or_slice: int, -) -> stim.GateData: - pass -@overload -def __getitem__( - self, - index_or_slice: slice, -) -> stim.CliffordString: - pass -def __getitem__( - self, - index_or_slice: Union[int, slice], -) -> Union[stim.GateData, stim.CliffordString]: - """Returns a Clifford or substring from the CliffordString. - - Args: - index_or_slice: The index of the Clifford to return, or the slice - corresponding to the sub CliffordString to return. - - Returns: - The indexed Clifford (as a stim.GateData instance) or the sliced - CliffordString. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,X,Y,Z,H") - - >>> s[2] - stim.gate_data('Y') - - >>> s[-1] - stim.gate_data('H') - - >>> s[:-1] - stim.CliffordString("I,X,Y,Z") - - >>> s[::2] - stim.CliffordString("I,Y,H") - """ -``` - - -```python -# stim.CliffordString.__iadd__ - -# (in class stim.CliffordString) -def __iadd__( - self, - rhs: stim.CliffordString, -) -> stim.CliffordString: - """Mutates the CliffordString by concatenating onto it. - - Args: - rhs: The suffix to concatenate onto the target CliffordString. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias += stim.CliffordString("Y,S") - >>> c - stim.CliffordString("I,X,H,Y,S") - """ -``` - - -```python -# stim.CliffordString.__imul__ - -# (in class stim.CliffordString) -def __imul__( - self, - rhs: Union[stim.CliffordString, int], -) -> stim.CliffordString: - """Inplace CliffordString multiplication. - - Mutates the CliffordString into itself multiplied by another CliffordString - (via pairwise Clifford multipliation) or by an integer (via repeating the - contents). - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> c = stim.CliffordString("S,X,X") - >>> alias = c - >>> alias *= stim.CliffordString("S,Z,H,Z") - >>> c - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias *= 2 - >>> c - stim.CliffordString("I,X,H,I,X,H") - """ -``` - - -```python -# stim.CliffordString.__init__ - -# (in class stim.CliffordString) -def __init__( - self, - arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], - /, -) -> None: - """Initializes a stim.CliffordString from the given argument. - - Args: - arg [position-only]: This can be a variety of types, including: - int: initializes an identity Clifford string of the given length. - str: initializes by parsing a comma-separated list of gate names. - stim.CliffordString: initializes by copying the given Clifford string. - stim.PauliString: initializes by copying from the given Pauli string - (ignores the sign of the Pauli string). - stim.Circuit: initializes a CliffordString equivalent to the action - of the circuit (as long as the circuit only contains single qubit - unitary operations and annotations). - Iterable: initializes by interpreting each item as a Clifford. - Each item can be a single-qubit Clifford gate name (like "SQRT_X") - or stim.GateData instance. - - Examples: - >>> import stim - - >>> stim.CliffordString(5) - stim.CliffordString("I,I,I,I,I") - - >>> stim.CliffordString("X,Y,Z,SQRT_X") - stim.CliffordString("X,Y,Z,SQRT_X") - - >>> stim.CliffordString(["H", stim.gate_data("S")]) - stim.CliffordString("H,S") - - >>> stim.CliffordString(stim.PauliString("XYZ")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.Circuit(''' - ... H 0 1 2 - ... S 2 3 - ... TICK - ... S 3 - ... I 6 - ... ''')) - stim.CliffordString("H,H,C_ZYX,Z,I,I,I") - """ -``` - - -```python -# stim.CliffordString.__ipow__ - -# (in class stim.CliffordString) -def __ipow__( - self, - num_qubits: int, -) -> object: - """Mutates the CliffordString into itself raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 inverts the string). - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - >>> p **= 3 - >>> p - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p **= 2 - >>> p - stim.CliffordString("I,I,I,Z,I") - - >>> alias = p - >>> alias **= 2 - >>> p - stim.CliffordString("I,I,I,I,I") - """ -``` - - -```python -# stim.CliffordString.__len__ - -# (in class stim.CliffordString) -def __len__( - self, -) -> int: - """Returns the number of Clifford operations in the string. - - Examples: - >>> import stim - >>> len(stim.CliffordString("I,X,Y,Z,H")) - 5 - """ -``` - - -```python -# stim.CliffordString.__mul__ - -# (in class stim.CliffordString) -def __mul__( - self, - rhs: Union[stim.CliffordString, int], -) -> stim.CliffordString: - """CliffordString multiplication. - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Examples: - >>> import stim - - >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> stim.CliffordString("I,X,H") * 3 - stim.CliffordString("I,X,H,I,X,H,I,X,H") - """ -``` - - -```python -# stim.CliffordString.__ne__ - -# (in class stim.CliffordString) -def __ne__( - self, - arg0: stim.CliffordString, -) -> bool: - """Determines if two Clifford strings have non-identical contents. - """ -``` - - -```python -# stim.CliffordString.__pow__ - -# (in class stim.CliffordString) -def __pow__( - self, - power: int, -) -> stim.CliffordString: - """Returns the CliffordString raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 returns the inverse string). - - Returns: - The Clifford string raised to the power. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**0 - stim.CliffordString("I,I,I,I,I") - - >>> p**1 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**12000001 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**2 - stim.CliffordString("I,I,I,Z,C_ZYX") - - >>> p**3 - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p**-1 - stim.CliffordString("I,X,H,S_DAG,C_ZYX") - """ -``` - - -```python -# stim.CliffordString.__repr__ - -# (in class stim.CliffordString) -def __repr__( - self, -) -> str: - """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. - """ -``` - - -```python -# stim.CliffordString.__rmul__ - -# (in class stim.CliffordString) -def __rmul__( - self, - lhs: int, -) -> stim.CliffordString: - """CliffordString left-multiplication. - - Args: - lhs: The number of times to repeat the Clifford string's contents. - - Returns: - The repeated Clifford string. - - Examples: - >>> import stim - - >>> 2 * stim.CliffordString("I,X,H") - stim.CliffordString("I,X,H,I,X,H") - - >>> 0 * stim.CliffordString("I,X,H") - stim.CliffordString("") - - >>> 5 * stim.CliffordString("I") - stim.CliffordString("I,I,I,I,I") - """ -``` - - -```python -# stim.CliffordString.__setitem__ - -# (in class stim.CliffordString) -def __setitem__( - self, - index_or_slice: Union[int, slice], - new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], -) -> None: - """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. - - Args: - index_or_slice: The index of the Clifford to overwrite, or the slice - of Cliffords to overwrite. - new_value: Specifies the value to write into the Clifford string. This can - be set to a few different types of values: - - str: Name of the single qubit Clifford gate to write to the index or - broadcast over the slice. - - stim.GateData: The single qubit Clifford gate to write to the index - or broadcast over the slice. - - stim.Tableau: Must be a single qubit tableau. Specifies the single - qubit Clifford gate to write to the index or broadcast over the - slice. - - stim.CliffordString: String of Cliffords to write into the slice. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,I,I,I,I") - - >>> s[1] = 'H' - >>> s - stim.CliffordString("I,H,I,I,I") - - >>> s[2:] = 'SQRT_X' - >>> s - stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[0] = stim.gate_data('S_DAG').inverse - >>> s - stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[:] = 'I' - >>> s - stim.CliffordString("I,I,I,I,I") - - >>> s[::2] = stim.CliffordString("X,Y,Z") - >>> s - stim.CliffordString("X,I,Y,I,Z") - - >>> s[0] = stim.Tableau.from_named_gate("H") - >>> s - stim.CliffordString("H,I,Y,I,Z") - - >>> s[:] = stim.Tableau.from_named_gate("S") - >>> s - stim.CliffordString("S,S,S,S,S") - - >>> s[:4] = stim.PauliString("IXYZ") - >>> s - stim.CliffordString("I,X,Y,Z,S") - """ -``` - - -```python -# stim.CliffordString.__str__ - -# (in class stim.CliffordString) -def __str__( - self, -) -> str: - """Returns a string representation of the CliffordString's operations. - """ -``` - - -```python -# stim.CliffordString.all_cliffords_string - -# (in class stim.CliffordString) -@staticmethod -def all_cliffords_string( -) -> stim.CliffordString: - """Returns a stim.CliffordString containing each single qubit Clifford once. - - Useful for things like testing that a method works on every single Clifford. - - Examples: - >>> import stim - >>> cliffords = stim.CliffordString.all_cliffords_string() - >>> len(cliffords) - 24 - - >>> print(cliffords[:8]) - I,X,Y,Z,H_XY,S,S_DAG,H_NXY - - >>> print(cliffords[8:16]) - H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG - - >>> print(cliffords[16:]) - C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX - """ -``` - - -```python -# stim.CliffordString.copy - -# (in class stim.CliffordString) -def copy( - self, -) -> stim.CliffordString: - """Returns a copy of the CliffordString. - - Returns: - The copy. - - Examples: - >>> import stim - >>> c = stim.CliffordString("H,X") - >>> alias = c - >>> copy = c.copy() - >>> c *= 5 - >>> alias - stim.CliffordString("H,X,H,X,H,X,H,X,H,X") - >>> copy - stim.CliffordString("H,X") - """ -``` - - -```python -# stim.CliffordString.random - -# (in class stim.CliffordString) -@staticmethod -def random( - num_qubits: int, -) -> stim.CliffordString: - """Samples a uniformly random CliffordString. - - Args: - num_qubits: The number of qubits the CliffordString should act upon. - - Examples: - >>> import stim - >>> p = stim.CliffordString.random(5) - >>> len(p) - 5 - - Returns: - The sampled Clifford string. - """ -``` - - -```python -# stim.CliffordString.x_outputs - -# (in class stim.CliffordString) -def x_outputs( - self, - *, - bit_packed_signs: bool = False, -) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates an X input into. - - For example, H conjugates X into +Z and S_DAG conjugates X into -Y. - - Combined with `z_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() - >>> x_paulis - stim.PauliString("+XXZY") - >>> x_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ -``` - - -```python -# stim.CliffordString.y_outputs - -# (in class stim.CliffordString) -def y_outputs( - self, - *, - bit_packed_signs: bool = False, -) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Y input into. - - For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() - >>> y_paulis - stim.PauliString("+YYYX") - >>> y_signs - array([False, True, True, True]) - - >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] - array([14], dtype=uint8) - """ -``` - - -```python -# stim.CliffordString.z_outputs - -# (in class stim.CliffordString) -def z_outputs( - self, - *, - bit_packed_signs: bool = False, -) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Z input into. - - For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. - - Combined with `x_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() - >>> z_paulis - stim.PauliString("+ZZXZ") - >>> z_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ -``` - ```python # stim.CompiledDemSampler @@ -5960,13 +5230,13 @@ def sample_write( shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + det_out_format: str = "01", obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: str = "01", err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + err_out_format: str = "01", replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + replay_err_in_format: str = "01", ) -> None: """Samples the detector error model and writes the results to disk. @@ -6227,9 +5497,9 @@ def sample_write( shots: int, *, filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -6440,8 +5710,8 @@ def sample_write( self, shots: int, *, - filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + filepath: str, + format: str = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -6568,7 +5838,7 @@ def convert( *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -6667,15 +5937,15 @@ def convert( def convert_file( self, *, - measurements_filepath: Union[str, pathlib.Path], - measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, - sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - detection_events_filepath: Union[str, pathlib.Path], - detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + measurements_filepath: str, + measurements_format: str = '01', + sweep_bits_filepath: str = None, + sweep_bits_format: str = '01', + detection_events_filepath: str, + detection_events_format: str = '01', append_observables: bool = False, - obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_filepath: str = None, + obs_out_format: str = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -8155,7 +7425,7 @@ def copy( # (in class stim.DetectorErrorModel) def diagram( self, - type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', + type: str, ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -10029,7 +9299,7 @@ def __init__( the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Args: + Arguments: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -11794,7 +11064,7 @@ def __imul__( # (in class stim.PauliString) def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -11807,7 +11077,7 @@ def __init__( pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Args: + Arguments: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -12414,7 +11684,7 @@ def from_numpy( def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -12753,7 +12023,7 @@ def to_tableau( def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -13556,7 +12826,7 @@ def from_stabilizers( def from_state_vector( state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -13624,7 +12894,7 @@ def from_state_vector( def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -14137,7 +13407,7 @@ def then( # (in class stim.Tableau) def to_circuit( self, - method: Literal["elimination", "graph_state"] = 'elimination', + method: 'Literal["elimination", "graph_state"]' = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -14532,7 +13802,7 @@ def to_stabilizers( def to_state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -14591,7 +13861,7 @@ def to_state_vector( def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -16733,7 +16003,7 @@ def set_state_from_state_vector( self, state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -16914,7 +16184,7 @@ def sqrt_y_dag( def state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -17542,7 +16812,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -17553,18 +16823,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -18026,7 +17296,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: str, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, diff --git a/doc/sinter_api.md b/doc/sinter_api.md index b8eb87d8a..a29c5b19c 100644 --- a/doc/sinter_api.md +++ b/doc/sinter_api.md @@ -161,11 +161,11 @@ class CollectionOptions: biggest batch size that can finish in under the given number of seconds. Limits each batch to be no larger than that. """ - max_shots: Union = None - max_errors: Union = None - start_batch_size: Union = None - max_batch_size: Union = None - max_batch_seconds: Union = None + max_shots: Optional[int] = None + max_errors: Optional[int] = None + start_batch_size: Optional[int] = None + max_batch_size: Optional[int] = None + max_batch_seconds: Optional[float] = None ``` @@ -461,9 +461,9 @@ class Fit: of the best fit's square error, or whose likelihood was within some maximum Bayes factor of the max likelihood hypothesis. """ - low: Union - best: Union - high: Union + low: Optional[float] + best: Optional[float] + high: Optional[float] ``` @@ -586,16 +586,16 @@ class Task: def __init__( self, *, - circuit: stim.Circuit | None = None, - decoder: str | None = None, - detector_error_model: stim.DetectorErrorModel | None = None, - postselection_mask: np.ndarray | None = None, - postselected_observables_mask: np.ndarray | None = None, + circuit: Optional[stim.Circuit] = None, + decoder: Optional[str] = None, + detector_error_model: Optional[stim.DetectorErrorModel] = None, + postselection_mask: Optional[np.ndarray] = None, + postselected_observables_mask: Optional[np.ndarray] = None, json_metadata: Any = None, collection_options: sinter.CollectionOptions = sinter.CollectionOptions(), skip_validation: bool = False, - circuit_path: str | pathlib.Path | None = None, - _unvalidated_strong_id: str | None = None, + circuit_path: Union[str, pathlib.Path, NoneType] = None, + _unvalidated_strong_id: Optional[str] = None, ) -> None: """ Args: @@ -852,7 +852,7 @@ def to_csv_line( >>> print(sinter.CSV_HEADER) shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts >>> print(stat.to_csv_line()) - 22, 3, 0, 5.00,pymatching,test,"{""a"":[1,2,3]}", + 22, 3, 0, 5,pymatching,test,"{""a"":[1,2,3]}", """ ``` @@ -864,14 +864,14 @@ def to_csv_line( def with_edits( self, *, - strong_id: str | None = None, - decoder: str | None = None, - json_metadata: Any | None = None, - shots: int | None = None, - errors: int | None = None, - discards: int | None = None, - seconds: float | None = None, - custom_counts: Counter[str] | None = None, + strong_id: Optional[str] = None, + decoder: Optional[str] = None, + json_metadata: Optional[Any] = None, + shots: Optional[int] = None, + errors: Optional[int] = None, + discards: Optional[int] = None, + seconds: Optional[float] = None, + custom_counts: Optional[Counter[str]] = None, ) -> sinter.TaskStats: ``` @@ -925,23 +925,23 @@ def better_sorted_str_terms( def collect( *, num_workers: int, - tasks: Iterator[sinter.Task] | Iterable[sinter.Task], - existing_data_filepaths: Iterable[str | pathlib.Path] = (), - save_resume_filepath: None | str | pathlib.Path = None, - progress_callback: Callable[[sinter.Progress], NoneType] | None = None, - max_shots: int | None = None, - max_errors: int | None = None, + tasks: Union[Iterator[sinter.Task], Iterable[sinter.Task]], + existing_data_filepaths: Iterable[Union[str, pathlib.Path]] = (), + save_resume_filepath: Union[NoneType, str, pathlib.Path] = None, + progress_callback: Optional[Callable[[sinter.Progress], NoneType]] = None, + max_shots: Optional[int] = None, + max_errors: Optional[int] = None, count_observable_error_combos: bool = False, count_detection_events: bool = False, - decoders: Iterable[str] | None = None, - max_batch_seconds: int | None = None, - max_batch_size: int | None = None, - start_batch_size: int | None = None, + decoders: Optional[Iterable[str]] = None, + max_batch_seconds: Optional[int] = None, + max_batch_size: Optional[int] = None, + start_batch_size: Optional[int] = None, print_progress: bool = False, - hint_num_tasks: int | None = None, - custom_decoders: Dict[str, sinter.Decoder | sinter.Sampler] | None = None, - custom_error_count_key: str | None = None, - allowed_cpu_affinity_ids: Iterable[int] | None = None, + hint_num_tasks: Optional[int] = None, + custom_decoders: Optional[Dict[str, Union[sinter.Decoder, sinter.Sampler]]] = None, + custom_error_count_key: Optional[str] = None, + allowed_cpu_affinity_ids: Optional[Iterable[int]] = None, ) -> List[sinter.TaskStats]: """Collects statistics from the given tasks, using multiprocessing. @@ -1252,20 +1252,20 @@ def group_by( def iter_collect( *, num_workers: int, - tasks: Iterator[sinter.Task] | Iterable[sinter.Task], - hint_num_tasks: int | None = None, - additional_existing_data: None | Dict[str, sinter.TaskStats] | Iterable[sinter.TaskStats] = None, - max_shots: int | None = None, - max_errors: int | None = None, - decoders: Iterable[str] | None = None, - max_batch_seconds: int | None = None, - max_batch_size: int | None = None, - start_batch_size: int | None = None, + tasks: Union[Iterator[sinter.Task], Iterable[sinter.Task]], + hint_num_tasks: Optional[int] = None, + additional_existing_data: Union[NoneType, Dict[str, sinter.TaskStats], Iterable[sinter.TaskStats]] = None, + max_shots: Optional[int] = None, + max_errors: Optional[int] = None, + decoders: Optional[Iterable[str]] = None, + max_batch_seconds: Optional[int] = None, + max_batch_size: Optional[int] = None, + start_batch_size: Optional[int] = None, count_observable_error_combos: bool = False, count_detection_events: bool = False, - custom_decoders: Dict[str, sinter.Decoder | sinter.Sampler] | None = None, - custom_error_count_key: str | None = None, - allowed_cpu_affinity_ids: Iterable[int] | None = None, + custom_decoders: Optional[Dict[str, Union[sinter.Decoder, sinter.Sampler]]] = None, + custom_error_count_key: Optional[str] = None, + allowed_cpu_affinity_ids: Optional[Iterable[int]] = None, ) -> Iterator[sinter.Progress]: """Iterates error correction statistics collected from worker processes. @@ -1377,7 +1377,7 @@ def iter_collect( # (at top-level in the sinter module) def log_binomial( *, - p: float | np.ndarray, + p: Union[float, np.ndarray], n: int, hits: int, ) -> np.ndarray: @@ -1466,7 +1466,7 @@ def plot_discard_rate( group_func: Callable[[sinter.TaskStats], ~TCurveId] = lambda _: None, filter_func: Callable[[sinter.TaskStats], Any] = lambda _: True, plot_args_func: Callable[[int, ~TCurveId, List[sinter.TaskStats]], Dict[str, Any]] = lambda index, group_key, group_stats: dict(), - highlight_max_likelihood_factor: float | None = 1000.0, + highlight_max_likelihood_factor: Optional[float] = 1000.0, point_label_func: Callable[[sinter.TaskStats], Any] = lambda _: None, ) -> None: """Plots discard rates in curves with uncertainty highlights. @@ -1530,8 +1530,8 @@ def plot_error_rate( group_func: Callable[[sinter.TaskStats], ~TCurveId] = lambda _: None, filter_func: Callable[[sinter.TaskStats], Any] = lambda _: True, plot_args_func: Callable[[int, ~TCurveId, List[sinter.TaskStats]], Dict[str, Any]] = lambda index, group_key, group_stats: dict(), - highlight_max_likelihood_factor: float | None = 1000.0, - line_fits: Tuple[Literal['linear', 'log', 'sqrt'], Literal['linear', 'log', 'sqrt']] | None = None, + highlight_max_likelihood_factor: Optional[float] = 1000.0, + line_fits: Optional[Tuple[Literal['linear', 'log', 'sqrt'], Literal['linear', 'log', 'sqrt']]] = None, point_label_func: Callable[[sinter.TaskStats], Any] = lambda _: None, ) -> None: """Plots error rates in curves with uncertainty highlights. @@ -1593,7 +1593,7 @@ def plot_error_rate( # (at top-level in the sinter module) def post_selection_mask_from_4th_coord( - dem: stim.Circuit | stim.DetectorErrorModel, + dem: Union[stim.Circuit, stim.DetectorErrorModel], ) -> np.ndarray: """Returns a mask that postselects detector's with non-zero 4th coordinate. @@ -1666,7 +1666,7 @@ def predict_observables( dets: np.ndarray, decoder: str, bit_pack_result: bool = False, - custom_decoders: Dict[str, sinter.Decoder] | None = None, + custom_decoders: Optional[Dict[str, sinter.Decoder]] = None, ) -> np.ndarray: """Predicts which observables were flipped based on detection event data. @@ -1729,7 +1729,7 @@ def predict_observables_bit_packed( dem: stim.DetectorErrorModel, dets_bit_packed: np.ndarray, decoder: str, - custom_decoders: Dict[str, sinter.Decoder] | None = None, + custom_decoders: Optional[Dict[str, sinter.Decoder]] = None, ) -> np.ndarray: """Predicts which observables were flipped based on detection event data. @@ -1786,14 +1786,14 @@ def predict_observables_bit_packed( def predict_on_disk( *, decoder: str, - dem_path: str | pathlib.Path, - dets_path: str | pathlib.Path, + dem_path: Union[str, pathlib.Path], + dets_path: Union[str, pathlib.Path], dets_format: str, - obs_out_path: str | pathlib.Path, + obs_out_path: Union[str, pathlib.Path], obs_out_format: str, postselect_detectors_with_non_zero_4th_coord: bool = False, - discards_out_path: str | pathlib.Path | None = None, - discards_out_format: str | None = None, + discards_out_path: Union[str, pathlib.Path, NoneType] = None, + discards_out_format: Optional[str] = None, custom_decoders: Dict[str, sinter.Decoder] = None, ) -> None: """Performs decoding and postselection on disk. @@ -1866,11 +1866,11 @@ def read_stats_from_csv_files( # (at top-level in the sinter module) def shot_error_rate_to_piece_error_rate( - shot_error_rate: float | sinter.Fit, + shot_error_rate: Union[float, sinter.Fit], *, pieces: float, values: float = 1, -) -> float | sinter.Fit: +) -> Union[float, sinter.Fit]: """Convert from total error rate to per-piece error rate. Args: diff --git a/doc/stim.pyi b/doc/stim.pyi index d71851394..0f12cbc9e 100644 --- a/doc/stim.pyi +++ b/doc/stim.pyi @@ -1049,7 +1049,7 @@ class Circuit: """ def diagram( self, - type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', + type: str = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -3889,560 +3889,6 @@ class CircuitTargetsInsideInstruction: >>> loc.instruction_targets.targets_in_range [stim.GateTargetWithCoords(0, [])] """ -class CliffordString: - """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). - - Represents a collection of Clifford operations applied pairwise to a - collection of qubits. Ignores global phase. - - Examples: - >>> import stim - >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") - stim.CliffordString("I,C_ZYX,SQRT_X_DAG") - """ - def __add__( - self, - rhs: stim.CliffordString, - ) -> stim.CliffordString: - """Concatenates two CliffordStrings. - - Args: - rhs: The suffix of the concatenation. - - Returns: - The concatenated Clifford string. - - Examples: - >>> import stim - >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") - stim.CliffordString("I,X,H,Y,S") - """ - def __eq__( - self, - arg0: stim.CliffordString, - ) -> bool: - """Determines if two Clifford strings have identical contents. - """ - @overload - def __getitem__( - self, - index_or_slice: int, - ) -> stim.GateData: - pass - @overload - def __getitem__( - self, - index_or_slice: slice, - ) -> stim.CliffordString: - pass - def __getitem__( - self, - index_or_slice: Union[int, slice], - ) -> Union[stim.GateData, stim.CliffordString]: - """Returns a Clifford or substring from the CliffordString. - - Args: - index_or_slice: The index of the Clifford to return, or the slice - corresponding to the sub CliffordString to return. - - Returns: - The indexed Clifford (as a stim.GateData instance) or the sliced - CliffordString. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,X,Y,Z,H") - - >>> s[2] - stim.gate_data('Y') - - >>> s[-1] - stim.gate_data('H') - - >>> s[:-1] - stim.CliffordString("I,X,Y,Z") - - >>> s[::2] - stim.CliffordString("I,Y,H") - """ - def __iadd__( - self, - rhs: stim.CliffordString, - ) -> stim.CliffordString: - """Mutates the CliffordString by concatenating onto it. - - Args: - rhs: The suffix to concatenate onto the target CliffordString. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias += stim.CliffordString("Y,S") - >>> c - stim.CliffordString("I,X,H,Y,S") - """ - def __imul__( - self, - rhs: Union[stim.CliffordString, int], - ) -> stim.CliffordString: - """Inplace CliffordString multiplication. - - Mutates the CliffordString into itself multiplied by another CliffordString - (via pairwise Clifford multipliation) or by an integer (via repeating the - contents). - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> c = stim.CliffordString("S,X,X") - >>> alias = c - >>> alias *= stim.CliffordString("S,Z,H,Z") - >>> c - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias *= 2 - >>> c - stim.CliffordString("I,X,H,I,X,H") - """ - def __init__( - self, - arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], - /, - ) -> None: - """Initializes a stim.CliffordString from the given argument. - - Args: - arg [position-only]: This can be a variety of types, including: - int: initializes an identity Clifford string of the given length. - str: initializes by parsing a comma-separated list of gate names. - stim.CliffordString: initializes by copying the given Clifford string. - stim.PauliString: initializes by copying from the given Pauli string - (ignores the sign of the Pauli string). - stim.Circuit: initializes a CliffordString equivalent to the action - of the circuit (as long as the circuit only contains single qubit - unitary operations and annotations). - Iterable: initializes by interpreting each item as a Clifford. - Each item can be a single-qubit Clifford gate name (like "SQRT_X") - or stim.GateData instance. - - Examples: - >>> import stim - - >>> stim.CliffordString(5) - stim.CliffordString("I,I,I,I,I") - - >>> stim.CliffordString("X,Y,Z,SQRT_X") - stim.CliffordString("X,Y,Z,SQRT_X") - - >>> stim.CliffordString(["H", stim.gate_data("S")]) - stim.CliffordString("H,S") - - >>> stim.CliffordString(stim.PauliString("XYZ")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.Circuit(''' - ... H 0 1 2 - ... S 2 3 - ... TICK - ... S 3 - ... I 6 - ... ''')) - stim.CliffordString("H,H,C_ZYX,Z,I,I,I") - """ - def __ipow__( - self, - num_qubits: int, - ) -> object: - """Mutates the CliffordString into itself raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 inverts the string). - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - >>> p **= 3 - >>> p - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p **= 2 - >>> p - stim.CliffordString("I,I,I,Z,I") - - >>> alias = p - >>> alias **= 2 - >>> p - stim.CliffordString("I,I,I,I,I") - """ - def __len__( - self, - ) -> int: - """Returns the number of Clifford operations in the string. - - Examples: - >>> import stim - >>> len(stim.CliffordString("I,X,Y,Z,H")) - 5 - """ - def __mul__( - self, - rhs: Union[stim.CliffordString, int], - ) -> stim.CliffordString: - """CliffordString multiplication. - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Examples: - >>> import stim - - >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> stim.CliffordString("I,X,H") * 3 - stim.CliffordString("I,X,H,I,X,H,I,X,H") - """ - def __ne__( - self, - arg0: stim.CliffordString, - ) -> bool: - """Determines if two Clifford strings have non-identical contents. - """ - def __pow__( - self, - power: int, - ) -> stim.CliffordString: - """Returns the CliffordString raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 returns the inverse string). - - Returns: - The Clifford string raised to the power. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**0 - stim.CliffordString("I,I,I,I,I") - - >>> p**1 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**12000001 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**2 - stim.CliffordString("I,I,I,Z,C_ZYX") - - >>> p**3 - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p**-1 - stim.CliffordString("I,X,H,S_DAG,C_ZYX") - """ - def __repr__( - self, - ) -> str: - """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. - """ - def __rmul__( - self, - lhs: int, - ) -> stim.CliffordString: - """CliffordString left-multiplication. - - Args: - lhs: The number of times to repeat the Clifford string's contents. - - Returns: - The repeated Clifford string. - - Examples: - >>> import stim - - >>> 2 * stim.CliffordString("I,X,H") - stim.CliffordString("I,X,H,I,X,H") - - >>> 0 * stim.CliffordString("I,X,H") - stim.CliffordString("") - - >>> 5 * stim.CliffordString("I") - stim.CliffordString("I,I,I,I,I") - """ - def __setitem__( - self, - index_or_slice: Union[int, slice], - new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], - ) -> None: - """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. - - Args: - index_or_slice: The index of the Clifford to overwrite, or the slice - of Cliffords to overwrite. - new_value: Specifies the value to write into the Clifford string. This can - be set to a few different types of values: - - str: Name of the single qubit Clifford gate to write to the index or - broadcast over the slice. - - stim.GateData: The single qubit Clifford gate to write to the index - or broadcast over the slice. - - stim.Tableau: Must be a single qubit tableau. Specifies the single - qubit Clifford gate to write to the index or broadcast over the - slice. - - stim.CliffordString: String of Cliffords to write into the slice. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,I,I,I,I") - - >>> s[1] = 'H' - >>> s - stim.CliffordString("I,H,I,I,I") - - >>> s[2:] = 'SQRT_X' - >>> s - stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[0] = stim.gate_data('S_DAG').inverse - >>> s - stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[:] = 'I' - >>> s - stim.CliffordString("I,I,I,I,I") - - >>> s[::2] = stim.CliffordString("X,Y,Z") - >>> s - stim.CliffordString("X,I,Y,I,Z") - - >>> s[0] = stim.Tableau.from_named_gate("H") - >>> s - stim.CliffordString("H,I,Y,I,Z") - - >>> s[:] = stim.Tableau.from_named_gate("S") - >>> s - stim.CliffordString("S,S,S,S,S") - - >>> s[:4] = stim.PauliString("IXYZ") - >>> s - stim.CliffordString("I,X,Y,Z,S") - """ - def __str__( - self, - ) -> str: - """Returns a string representation of the CliffordString's operations. - """ - @staticmethod - def all_cliffords_string( - ) -> stim.CliffordString: - """Returns a stim.CliffordString containing each single qubit Clifford once. - - Useful for things like testing that a method works on every single Clifford. - - Examples: - >>> import stim - >>> cliffords = stim.CliffordString.all_cliffords_string() - >>> len(cliffords) - 24 - - >>> print(cliffords[:8]) - I,X,Y,Z,H_XY,S,S_DAG,H_NXY - - >>> print(cliffords[8:16]) - H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG - - >>> print(cliffords[16:]) - C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX - """ - def copy( - self, - ) -> stim.CliffordString: - """Returns a copy of the CliffordString. - - Returns: - The copy. - - Examples: - >>> import stim - >>> c = stim.CliffordString("H,X") - >>> alias = c - >>> copy = c.copy() - >>> c *= 5 - >>> alias - stim.CliffordString("H,X,H,X,H,X,H,X,H,X") - >>> copy - stim.CliffordString("H,X") - """ - @staticmethod - def random( - num_qubits: int, - ) -> stim.CliffordString: - """Samples a uniformly random CliffordString. - - Args: - num_qubits: The number of qubits the CliffordString should act upon. - - Examples: - >>> import stim - >>> p = stim.CliffordString.random(5) - >>> len(p) - 5 - - Returns: - The sampled Clifford string. - """ - def x_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates an X input into. - - For example, H conjugates X into +Z and S_DAG conjugates X into -Y. - - Combined with `z_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() - >>> x_paulis - stim.PauliString("+XXZY") - >>> x_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ - def y_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Y input into. - - For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() - >>> y_paulis - stim.PauliString("+YYYX") - >>> y_signs - array([False, True, True, True]) - - >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] - array([14], dtype=uint8) - """ - def z_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Z input into. - - For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. - - Combined with `x_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() - >>> z_paulis - stim.PauliString("+ZZXZ") - >>> z_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ class CompiledDemSampler: """A helper class for efficiently sampler from a detector error model. @@ -4627,13 +4073,13 @@ class CompiledDemSampler: shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + det_out_format: str = "01", obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: str = "01", err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + err_out_format: str = "01", replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + replay_err_in_format: str = "01", ) -> None: """Samples the detector error model and writes the results to disk. @@ -4887,9 +4333,9 @@ class CompiledDetectorSampler: shots: int, *, filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -5093,8 +4539,8 @@ class CompiledMeasurementSampler: self, shots: int, *, - filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + filepath: str, + format: str = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -5193,7 +4639,7 @@ class CompiledMeasurementsToDetectionEventsConverter: *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -5285,15 +4731,15 @@ class CompiledMeasurementsToDetectionEventsConverter: def convert_file( self, *, - measurements_filepath: Union[str, pathlib.Path], - measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, - sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - detection_events_filepath: Union[str, pathlib.Path], - detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + measurements_filepath: str, + measurements_format: str = '01', + sweep_bits_filepath: str = None, + sweep_bits_format: str = '01', + detection_events_filepath: str, + detection_events_format: str = '01', append_observables: bool = False, - obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_filepath: str = None, + obs_out_format: str = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -6388,7 +5834,7 @@ class DetectorErrorModel: """ def diagram( self, - type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', + type: str, ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -7982,7 +7428,7 @@ class Flow: the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Args: + Arguments: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -9334,7 +8780,7 @@ class PauliString: """ def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -9347,7 +8793,7 @@ class PauliString: pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Args: + Arguments: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -9841,7 +9287,7 @@ class PauliString: def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -10131,7 +9577,7 @@ class PauliString: def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -10766,7 +10212,7 @@ class Tableau: def from_state_vector( state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -10827,7 +10273,7 @@ class Tableau: def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -11256,7 +10702,7 @@ class Tableau: """ def to_circuit( self, - method: Literal["elimination", "graph_state"] = 'elimination', + method: 'Literal["elimination", "graph_state"]' = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -11623,7 +11069,7 @@ class Tableau: def to_state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -11675,7 +11121,7 @@ class Tableau: def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -13397,7 +12843,7 @@ class TableauSimulator: self, state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -13543,7 +12989,7 @@ class TableauSimulator: def state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -14038,7 +13484,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -14049,18 +13495,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -14431,7 +13877,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: str, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, diff --git a/glue/python/src/stim/__init__.pyi b/glue/python/src/stim/__init__.pyi index d71851394..0f12cbc9e 100644 --- a/glue/python/src/stim/__init__.pyi +++ b/glue/python/src/stim/__init__.pyi @@ -1049,7 +1049,7 @@ class Circuit: """ def diagram( self, - type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', + type: str = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -3889,560 +3889,6 @@ class CircuitTargetsInsideInstruction: >>> loc.instruction_targets.targets_in_range [stim.GateTargetWithCoords(0, [])] """ -class CliffordString: - """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). - - Represents a collection of Clifford operations applied pairwise to a - collection of qubits. Ignores global phase. - - Examples: - >>> import stim - >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") - stim.CliffordString("I,C_ZYX,SQRT_X_DAG") - """ - def __add__( - self, - rhs: stim.CliffordString, - ) -> stim.CliffordString: - """Concatenates two CliffordStrings. - - Args: - rhs: The suffix of the concatenation. - - Returns: - The concatenated Clifford string. - - Examples: - >>> import stim - >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") - stim.CliffordString("I,X,H,Y,S") - """ - def __eq__( - self, - arg0: stim.CliffordString, - ) -> bool: - """Determines if two Clifford strings have identical contents. - """ - @overload - def __getitem__( - self, - index_or_slice: int, - ) -> stim.GateData: - pass - @overload - def __getitem__( - self, - index_or_slice: slice, - ) -> stim.CliffordString: - pass - def __getitem__( - self, - index_or_slice: Union[int, slice], - ) -> Union[stim.GateData, stim.CliffordString]: - """Returns a Clifford or substring from the CliffordString. - - Args: - index_or_slice: The index of the Clifford to return, or the slice - corresponding to the sub CliffordString to return. - - Returns: - The indexed Clifford (as a stim.GateData instance) or the sliced - CliffordString. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,X,Y,Z,H") - - >>> s[2] - stim.gate_data('Y') - - >>> s[-1] - stim.gate_data('H') - - >>> s[:-1] - stim.CliffordString("I,X,Y,Z") - - >>> s[::2] - stim.CliffordString("I,Y,H") - """ - def __iadd__( - self, - rhs: stim.CliffordString, - ) -> stim.CliffordString: - """Mutates the CliffordString by concatenating onto it. - - Args: - rhs: The suffix to concatenate onto the target CliffordString. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias += stim.CliffordString("Y,S") - >>> c - stim.CliffordString("I,X,H,Y,S") - """ - def __imul__( - self, - rhs: Union[stim.CliffordString, int], - ) -> stim.CliffordString: - """Inplace CliffordString multiplication. - - Mutates the CliffordString into itself multiplied by another CliffordString - (via pairwise Clifford multipliation) or by an integer (via repeating the - contents). - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> c = stim.CliffordString("S,X,X") - >>> alias = c - >>> alias *= stim.CliffordString("S,Z,H,Z") - >>> c - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> c = stim.CliffordString("I,X,H") - >>> alias = c - >>> alias *= 2 - >>> c - stim.CliffordString("I,X,H,I,X,H") - """ - def __init__( - self, - arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], - /, - ) -> None: - """Initializes a stim.CliffordString from the given argument. - - Args: - arg [position-only]: This can be a variety of types, including: - int: initializes an identity Clifford string of the given length. - str: initializes by parsing a comma-separated list of gate names. - stim.CliffordString: initializes by copying the given Clifford string. - stim.PauliString: initializes by copying from the given Pauli string - (ignores the sign of the Pauli string). - stim.Circuit: initializes a CliffordString equivalent to the action - of the circuit (as long as the circuit only contains single qubit - unitary operations and annotations). - Iterable: initializes by interpreting each item as a Clifford. - Each item can be a single-qubit Clifford gate name (like "SQRT_X") - or stim.GateData instance. - - Examples: - >>> import stim - - >>> stim.CliffordString(5) - stim.CliffordString("I,I,I,I,I") - - >>> stim.CliffordString("X,Y,Z,SQRT_X") - stim.CliffordString("X,Y,Z,SQRT_X") - - >>> stim.CliffordString(["H", stim.gate_data("S")]) - stim.CliffordString("H,S") - - >>> stim.CliffordString(stim.PauliString("XYZ")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) - stim.CliffordString("X,Y,Z") - - >>> stim.CliffordString(stim.Circuit(''' - ... H 0 1 2 - ... S 2 3 - ... TICK - ... S 3 - ... I 6 - ... ''')) - stim.CliffordString("H,H,C_ZYX,Z,I,I,I") - """ - def __ipow__( - self, - num_qubits: int, - ) -> object: - """Mutates the CliffordString into itself raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 inverts the string). - - Returns: - The mutated Clifford string. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - >>> p **= 3 - >>> p - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p **= 2 - >>> p - stim.CliffordString("I,I,I,Z,I") - - >>> alias = p - >>> alias **= 2 - >>> p - stim.CliffordString("I,I,I,I,I") - """ - def __len__( - self, - ) -> int: - """Returns the number of Clifford operations in the string. - - Examples: - >>> import stim - >>> len(stim.CliffordString("I,X,Y,Z,H")) - 5 - """ - def __mul__( - self, - rhs: Union[stim.CliffordString, int], - ) -> stim.CliffordString: - """CliffordString multiplication. - - Args: - rhs: Either a stim.CliffordString or an int. If rhs is a - stim.CliffordString, then the Cliffords from each string are multiplied - pairwise. If rhs is an int, it is the number of times to repeat the - Clifford string's contents. - - Examples: - >>> import stim - - >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") - stim.CliffordString("Z,Y,SQRT_Y,Z") - - >>> stim.CliffordString("I,X,H") * 3 - stim.CliffordString("I,X,H,I,X,H,I,X,H") - """ - def __ne__( - self, - arg0: stim.CliffordString, - ) -> bool: - """Determines if two Clifford strings have non-identical contents. - """ - def __pow__( - self, - power: int, - ) -> stim.CliffordString: - """Returns the CliffordString raised to a power. - - Args: - power: The power to raise the CliffordString's Cliffords to. - This value can be negative (e.g. -1 returns the inverse string). - - Returns: - The Clifford string raised to the power. - - Examples: - >>> import stim - - >>> p = stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**0 - stim.CliffordString("I,I,I,I,I") - - >>> p**1 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**12000001 - stim.CliffordString("I,X,H,S,C_XYZ") - - >>> p**2 - stim.CliffordString("I,I,I,Z,C_ZYX") - - >>> p**3 - stim.CliffordString("I,X,H,S_DAG,I") - - >>> p**-1 - stim.CliffordString("I,X,H,S_DAG,C_ZYX") - """ - def __repr__( - self, - ) -> str: - """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. - """ - def __rmul__( - self, - lhs: int, - ) -> stim.CliffordString: - """CliffordString left-multiplication. - - Args: - lhs: The number of times to repeat the Clifford string's contents. - - Returns: - The repeated Clifford string. - - Examples: - >>> import stim - - >>> 2 * stim.CliffordString("I,X,H") - stim.CliffordString("I,X,H,I,X,H") - - >>> 0 * stim.CliffordString("I,X,H") - stim.CliffordString("") - - >>> 5 * stim.CliffordString("I") - stim.CliffordString("I,I,I,I,I") - """ - def __setitem__( - self, - index_or_slice: Union[int, slice], - new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], - ) -> None: - """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. - - Args: - index_or_slice: The index of the Clifford to overwrite, or the slice - of Cliffords to overwrite. - new_value: Specifies the value to write into the Clifford string. This can - be set to a few different types of values: - - str: Name of the single qubit Clifford gate to write to the index or - broadcast over the slice. - - stim.GateData: The single qubit Clifford gate to write to the index - or broadcast over the slice. - - stim.Tableau: Must be a single qubit tableau. Specifies the single - qubit Clifford gate to write to the index or broadcast over the - slice. - - stim.CliffordString: String of Cliffords to write into the slice. - - Examples: - >>> import stim - >>> s = stim.CliffordString("I,I,I,I,I") - - >>> s[1] = 'H' - >>> s - stim.CliffordString("I,H,I,I,I") - - >>> s[2:] = 'SQRT_X' - >>> s - stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[0] = stim.gate_data('S_DAG').inverse - >>> s - stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") - - >>> s[:] = 'I' - >>> s - stim.CliffordString("I,I,I,I,I") - - >>> s[::2] = stim.CliffordString("X,Y,Z") - >>> s - stim.CliffordString("X,I,Y,I,Z") - - >>> s[0] = stim.Tableau.from_named_gate("H") - >>> s - stim.CliffordString("H,I,Y,I,Z") - - >>> s[:] = stim.Tableau.from_named_gate("S") - >>> s - stim.CliffordString("S,S,S,S,S") - - >>> s[:4] = stim.PauliString("IXYZ") - >>> s - stim.CliffordString("I,X,Y,Z,S") - """ - def __str__( - self, - ) -> str: - """Returns a string representation of the CliffordString's operations. - """ - @staticmethod - def all_cliffords_string( - ) -> stim.CliffordString: - """Returns a stim.CliffordString containing each single qubit Clifford once. - - Useful for things like testing that a method works on every single Clifford. - - Examples: - >>> import stim - >>> cliffords = stim.CliffordString.all_cliffords_string() - >>> len(cliffords) - 24 - - >>> print(cliffords[:8]) - I,X,Y,Z,H_XY,S,S_DAG,H_NXY - - >>> print(cliffords[8:16]) - H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG - - >>> print(cliffords[16:]) - C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX - """ - def copy( - self, - ) -> stim.CliffordString: - """Returns a copy of the CliffordString. - - Returns: - The copy. - - Examples: - >>> import stim - >>> c = stim.CliffordString("H,X") - >>> alias = c - >>> copy = c.copy() - >>> c *= 5 - >>> alias - stim.CliffordString("H,X,H,X,H,X,H,X,H,X") - >>> copy - stim.CliffordString("H,X") - """ - @staticmethod - def random( - num_qubits: int, - ) -> stim.CliffordString: - """Samples a uniformly random CliffordString. - - Args: - num_qubits: The number of qubits the CliffordString should act upon. - - Examples: - >>> import stim - >>> p = stim.CliffordString.random(5) - >>> len(p) - 5 - - Returns: - The sampled Clifford string. - """ - def x_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates an X input into. - - For example, H conjugates X into +Z and S_DAG conjugates X into -Y. - - Combined with `z_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() - >>> x_paulis - stim.PauliString("+XXZY") - >>> x_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ - def y_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Y input into. - - For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() - >>> y_paulis - stim.PauliString("+YYYX") - >>> y_signs - array([False, True, True, True]) - - >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] - array([14], dtype=uint8) - """ - def z_outputs( - self, - *, - bit_packed_signs: bool = False, - ) -> Tuple[stim.PauliString, np.ndarray]: - """Returns what each Clifford in the CliffordString conjugates a Z input into. - - For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. - - Combined with `x_outputs`, the results of this method completely specify - the single qubit Clifford applied to each qubit. - - Args: - bit_packed_signs: Defaults to False. When False, the sign data is returned - in a numpy array with dtype `np.bool_`. When True, the dtype is instead - `np.uint8` and 8 bits are packed into each byte (in little endian - order). - - Returns: - A (paulis, signs) tuple. - - `paulis` has type stim.PauliString. Its sign is always positive. - - `signs` has type np.ndarray and an argument-dependent shape: - bit_packed_signs=False: - dtype=np.bool_ - shape=(num_qubits,) - bit_packed_signs=True: - dtype=np.uint8 - shape=(math.ceil(num_qubits / 8),) - - Examples: - >>> import stim - >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() - >>> z_paulis - stim.PauliString("+ZZXZ") - >>> z_signs - array([False, True, False, False]) - - >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] - array([2], dtype=uint8) - """ class CompiledDemSampler: """A helper class for efficiently sampler from a detector error model. @@ -4627,13 +4073,13 @@ class CompiledDemSampler: shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + det_out_format: str = "01", obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: str = "01", err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + err_out_format: str = "01", replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + replay_err_in_format: str = "01", ) -> None: """Samples the detector error model and writes the results to disk. @@ -4887,9 +4333,9 @@ class CompiledDetectorSampler: shots: int, *, filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -5093,8 +4539,8 @@ class CompiledMeasurementSampler: self, shots: int, *, - filepath: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + filepath: str, + format: str = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -5193,7 +4639,7 @@ class CompiledMeasurementsToDetectionEventsConverter: *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -5285,15 +4731,15 @@ class CompiledMeasurementsToDetectionEventsConverter: def convert_file( self, *, - measurements_filepath: Union[str, pathlib.Path], - measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, - sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', - detection_events_filepath: Union[str, pathlib.Path], - detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + measurements_filepath: str, + measurements_format: str = '01', + sweep_bits_filepath: str = None, + sweep_bits_format: str = '01', + detection_events_filepath: str, + detection_events_format: str = '01', append_observables: bool = False, - obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + obs_out_filepath: str = None, + obs_out_format: str = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -6388,7 +5834,7 @@ class DetectorErrorModel: """ def diagram( self, - type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', + type: str, ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -7982,7 +7428,7 @@ class Flow: the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Args: + Arguments: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -9334,7 +8780,7 @@ class PauliString: """ def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -9347,7 +8793,7 @@ class PauliString: pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Args: + Arguments: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -9841,7 +9287,7 @@ class PauliString: def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -10131,7 +9577,7 @@ class PauliString: def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -10766,7 +10212,7 @@ class Tableau: def from_state_vector( state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -10827,7 +10273,7 @@ class Tableau: def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -11256,7 +10702,7 @@ class Tableau: """ def to_circuit( self, - method: Literal["elimination", "graph_state"] = 'elimination', + method: 'Literal["elimination", "graph_state"]' = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -11623,7 +11069,7 @@ class Tableau: def to_state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -11675,7 +11121,7 @@ class Tableau: def to_unitary_matrix( self, *, - endian: Literal["little", "big"], + endian: str, ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -13397,7 +12843,7 @@ class TableauSimulator: self, state_vector: Iterable[float], *, - endian: Literal["little", "big"], + endian: str, ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -13543,7 +12989,7 @@ class TableauSimulator: def state_vector( self, *, - endian: Literal["little", "big"] = 'little', + endian: str = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -14038,7 +13484,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -14049,18 +13495,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: Literal[True], + separate_observables: 'Literal[True]', ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -14431,7 +13877,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], + format: str, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, From 28fcac3e5142f92105513c9a88c0e140a46c456a Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Wed, 21 Jan 2026 01:04:47 +0000 Subject: [PATCH 08/10] pip install .; dev/regen_docs.sh --- doc/gates.md | 2 +- doc/python_api_reference_vDev.md | 1108 ++++++++++++++++++++++++----- doc/stim.pyi | 936 +++++++++++++++++++----- glue/python/src/stim/__init__.pyi | 936 +++++++++++++++++++----- 4 files changed, 2410 insertions(+), 572 deletions(-) diff --git a/doc/gates.md b/doc/gates.md index 4f21ce09e..7f9825026 100644 --- a/doc/gates.md +++ b/doc/gates.md @@ -3579,7 +3579,7 @@ Example: # Sample errors from the distribution 10% XX, 20% YZ, 70% II. # Apply independently to qubit pairs (1,2), (5,6), and (8,3) - PAULI_CHANNEL_2(0,0,0, 0.1,0,0,0, 0,0,0,0.2, 0,0,0,0) 1 2 5 6 8 3 + PAULI_CHANNEL_2(0,0,0, 0,0.1,0,0, 0,0,0,0.2, 0,0,0,0) 1 2 5 6 8 3 Pauli Mixture: diff --git a/doc/python_api_reference_vDev.md b/doc/python_api_reference_vDev.md index cfef6f0be..6ba04c52f 100644 --- a/doc/python_api_reference_vDev.md +++ b/doc/python_api_reference_vDev.md @@ -109,6 +109,28 @@ API references for stable versions are kept on the [stim github wiki](https://gi - [`stim.CircuitTargetsInsideInstruction.target_range_end`](#stim.CircuitTargetsInsideInstruction.target_range_end) - [`stim.CircuitTargetsInsideInstruction.target_range_start`](#stim.CircuitTargetsInsideInstruction.target_range_start) - [`stim.CircuitTargetsInsideInstruction.targets_in_range`](#stim.CircuitTargetsInsideInstruction.targets_in_range) +- [`stim.CliffordString`](#stim.CliffordString) + - [`stim.CliffordString.__add__`](#stim.CliffordString.__add__) + - [`stim.CliffordString.__eq__`](#stim.CliffordString.__eq__) + - [`stim.CliffordString.__getitem__`](#stim.CliffordString.__getitem__) + - [`stim.CliffordString.__iadd__`](#stim.CliffordString.__iadd__) + - [`stim.CliffordString.__imul__`](#stim.CliffordString.__imul__) + - [`stim.CliffordString.__init__`](#stim.CliffordString.__init__) + - [`stim.CliffordString.__ipow__`](#stim.CliffordString.__ipow__) + - [`stim.CliffordString.__len__`](#stim.CliffordString.__len__) + - [`stim.CliffordString.__mul__`](#stim.CliffordString.__mul__) + - [`stim.CliffordString.__ne__`](#stim.CliffordString.__ne__) + - [`stim.CliffordString.__pow__`](#stim.CliffordString.__pow__) + - [`stim.CliffordString.__repr__`](#stim.CliffordString.__repr__) + - [`stim.CliffordString.__rmul__`](#stim.CliffordString.__rmul__) + - [`stim.CliffordString.__setitem__`](#stim.CliffordString.__setitem__) + - [`stim.CliffordString.__str__`](#stim.CliffordString.__str__) + - [`stim.CliffordString.all_cliffords_string`](#stim.CliffordString.all_cliffords_string) + - [`stim.CliffordString.copy`](#stim.CliffordString.copy) + - [`stim.CliffordString.random`](#stim.CliffordString.random) + - [`stim.CliffordString.x_outputs`](#stim.CliffordString.x_outputs) + - [`stim.CliffordString.y_outputs`](#stim.CliffordString.y_outputs) + - [`stim.CliffordString.z_outputs`](#stim.CliffordString.z_outputs) - [`stim.CompiledDemSampler`](#stim.CompiledDemSampler) - [`stim.CompiledDemSampler.sample`](#stim.CompiledDemSampler.sample) - [`stim.CompiledDemSampler.sample_write`](#stim.CompiledDemSampler.sample_write) @@ -500,8 +522,8 @@ class Circuit: # (in class stim.Circuit) def __add__( self, - second: stim.Circuit, -) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, +) -> stim._stim_polyfill.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -529,7 +551,7 @@ def __add__( # (in class stim.Circuit) def __eq__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -603,8 +625,8 @@ def __getitem__( # (in class stim.Circuit) def __iadd__( self, - second: stim.Circuit, -) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, +) -> stim._stim_polyfill.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -634,7 +656,7 @@ def __iadd__( def __imul__( self, repetitions: int, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -728,7 +750,7 @@ def __len__( def __mul__( self, repetitions: int, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -765,7 +787,7 @@ def __mul__( # (in class stim.Circuit) def __ne__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -791,7 +813,7 @@ def __repr__( def __rmul__( self, repetitions: int, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -1049,7 +1071,7 @@ def compile_detector_sampler( self, *, seed: object = None, -) -> stim.CompiledDetectorSampler: +) -> stim._stim_polyfill.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -1101,7 +1123,7 @@ def compile_m2d_converter( self, *, skip_reference_sample: bool = False, -) -> stim.CompiledMeasurementsToDetectionEventsConverter: +) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -1229,7 +1251,7 @@ def compile_sampler( # (in class stim.Circuit) def copy( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -1355,7 +1377,7 @@ def count_determined_measurements( # (in class stim.Circuit) def decomposed( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -1569,7 +1591,7 @@ def detector_error_model( approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1664,7 +1686,7 @@ def detector_error_model( # (in class stim.Circuit) def diagram( self, - type: str = 'timeline-text', + type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -1803,7 +1825,7 @@ def explain_detector_error_model_errors( *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, -) -> List[stim.ExplainedError]: +) -> List[stim._stim_polyfill.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1863,7 +1885,7 @@ def explain_detector_error_model_errors( # (in class stim.Circuit) def flattened( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -2021,7 +2043,7 @@ def generated( before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -2433,7 +2455,7 @@ def insert( # (in class stim.Circuit) def inverse( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2963,7 +2985,7 @@ def search_for_undetectable_logical_errors( dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, -) -> List[stim.ExplainedError]: +) -> List[stim._stim_polyfill.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -3135,7 +3157,7 @@ def shortest_graphlike_error( *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, -) -> List[stim.ExplainedError]: +) -> List[stim._stim_polyfill.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -3769,7 +3791,7 @@ def to_tableau( # (in class stim.Circuit) def with_inlined_feedback( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3830,7 +3852,7 @@ def with_inlined_feedback( # (in class stim.Circuit) def without_noise( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3864,7 +3886,7 @@ def without_noise( # (in class stim.Circuit) def without_tags( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3923,10 +3945,10 @@ def __init__( self, *, tick_offset: int, - flipped_pauli_product: List[stim.GateTargetWithCoords], + flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim.CircuitTargetsInsideInstruction, - stack_frames: List[stim.CircuitErrorLocationStackFrame], + instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, + stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -4013,7 +4035,7 @@ def flipped_measurement( @property def flipped_pauli_product( self, -) -> List[stim.GateTargetWithCoords]: +) -> List[stim._stim_polyfill.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -4039,7 +4061,7 @@ def flipped_pauli_product( @property def instruction_targets( self, -) -> stim.CircuitTargetsInsideInstruction: +) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -4097,7 +4119,7 @@ def noise_tag( @property def stack_frames( self, -) -> List[stim.CircuitErrorLocationStackFrame]: +) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -4337,7 +4359,7 @@ class CircuitInstruction: # (in class stim.CircuitInstruction) def __eq__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -4395,7 +4417,7 @@ def __init__( # (in class stim.CircuitInstruction) def __ne__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -4569,7 +4591,7 @@ def target_groups( # (in class stim.CircuitInstruction) def targets_copy( self, -) -> List[stim.GateTarget]: +) -> List[stim._stim_polyfill.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -4620,7 +4642,7 @@ class CircuitRepeatBlock: # (in class stim.CircuitRepeatBlock) def __eq__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ @@ -4634,7 +4656,7 @@ def __eq__( def __init__( self, repeat_count: int, - body: stim.Circuit, + body: stim._stim_polyfill.Circuit, *, tag: str = '', ) -> None: @@ -4665,7 +4687,7 @@ def __init__( # (in class stim.CircuitRepeatBlock) def __ne__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -4690,7 +4712,7 @@ def __repr__( # (in class stim.CircuitRepeatBlock) def body_copy( self, -) -> stim.Circuit: +) -> stim._stim_polyfill.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -4846,7 +4868,7 @@ def __init__( args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim.GateTargetWithCoords], + targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -5007,7 +5029,7 @@ def target_range_start( @property def targets_in_range( self, -) -> List[stim.GateTargetWithCoords]: +) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -5027,6 +5049,714 @@ def targets_in_range( """ ``` + +```python +# stim.CliffordString + +# (at top-level in the stim module) +class CliffordString: + """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). + + Represents a collection of Clifford operations applied pairwise to a + collection of qubits. Ignores global phase. + + Examples: + >>> import stim + >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") + stim.CliffordString("I,C_ZYX,SQRT_X_DAG") + """ +``` + + +```python +# stim.CliffordString.__add__ + +# (in class stim.CliffordString) +def __add__( + self, + rhs: stim._stim_polyfill.CliffordString, +) -> stim._stim_polyfill.CliffordString: + """Concatenates two CliffordStrings. + + Args: + rhs: The suffix of the concatenation. + + Returns: + The concatenated Clifford string. + + Examples: + >>> import stim + >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") + stim.CliffordString("I,X,H,Y,S") + """ +``` + + +```python +# stim.CliffordString.__eq__ + +# (in class stim.CliffordString) +def __eq__( + self, + arg0: stim._stim_polyfill.CliffordString, +) -> bool: + """Determines if two Clifford strings have identical contents. + """ +``` + + +```python +# stim.CliffordString.__getitem__ + +# (in class stim.CliffordString) +@overload +def __getitem__( + self, + index_or_slice: int, +) -> stim.GateData: + pass +@overload +def __getitem__( + self, + index_or_slice: slice, +) -> stim.CliffordString: + pass +def __getitem__( + self, + index_or_slice: Union[int, slice], +) -> Union[stim.GateData, stim.CliffordString]: + """Returns a Clifford or substring from the CliffordString. + + Args: + index_or_slice: The index of the Clifford to return, or the slice + corresponding to the sub CliffordString to return. + + Returns: + The indexed Clifford (as a stim.GateData instance) or the sliced + CliffordString. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,X,Y,Z,H") + + >>> s[2] + stim.gate_data('Y') + + >>> s[-1] + stim.gate_data('H') + + >>> s[:-1] + stim.CliffordString("I,X,Y,Z") + + >>> s[::2] + stim.CliffordString("I,Y,H") + """ +``` + + +```python +# stim.CliffordString.__iadd__ + +# (in class stim.CliffordString) +def __iadd__( + self, + rhs: stim._stim_polyfill.CliffordString, +) -> stim._stim_polyfill.CliffordString: + """Mutates the CliffordString by concatenating onto it. + + Args: + rhs: The suffix to concatenate onto the target CliffordString. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias += stim.CliffordString("Y,S") + >>> c + stim.CliffordString("I,X,H,Y,S") + """ +``` + + +```python +# stim.CliffordString.__imul__ + +# (in class stim.CliffordString) +def __imul__( + self, + rhs: Union[stim.CliffordString, int], +) -> stim.CliffordString: + """Inplace CliffordString multiplication. + + Mutates the CliffordString into itself multiplied by another CliffordString + (via pairwise Clifford multipliation) or by an integer (via repeating the + contents). + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> c = stim.CliffordString("S,X,X") + >>> alias = c + >>> alias *= stim.CliffordString("S,Z,H,Z") + >>> c + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias *= 2 + >>> c + stim.CliffordString("I,X,H,I,X,H") + """ +``` + + +```python +# stim.CliffordString.__init__ + +# (in class stim.CliffordString) +def __init__( + self, + arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], + /, +) -> None: + """Initializes a stim.CliffordString from the given argument. + + Args: + arg [position-only]: This can be a variety of types, including: + int: initializes an identity Clifford string of the given length. + str: initializes by parsing a comma-separated list of gate names. + stim.CliffordString: initializes by copying the given Clifford string. + stim.PauliString: initializes by copying from the given Pauli string + (ignores the sign of the Pauli string). + stim.Circuit: initializes a CliffordString equivalent to the action + of the circuit (as long as the circuit only contains single qubit + unitary operations and annotations). + Iterable: initializes by interpreting each item as a Clifford. + Each item can be a single-qubit Clifford gate name (like "SQRT_X") + or stim.GateData instance. + + Examples: + >>> import stim + + >>> stim.CliffordString(5) + stim.CliffordString("I,I,I,I,I") + + >>> stim.CliffordString("X,Y,Z,SQRT_X") + stim.CliffordString("X,Y,Z,SQRT_X") + + >>> stim.CliffordString(["H", stim.gate_data("S")]) + stim.CliffordString("H,S") + + >>> stim.CliffordString(stim.PauliString("XYZ")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.Circuit(''' + ... H 0 1 2 + ... S 2 3 + ... TICK + ... S 3 + ... I 6 + ... ''')) + stim.CliffordString("H,H,C_ZYX,Z,I,I,I") + """ +``` + + +```python +# stim.CliffordString.__ipow__ + +# (in class stim.CliffordString) +def __ipow__( + self, + num_qubits: int, +) -> object: + """Mutates the CliffordString into itself raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 inverts the string). + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + >>> p **= 3 + >>> p + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p **= 2 + >>> p + stim.CliffordString("I,I,I,Z,I") + + >>> alias = p + >>> alias **= 2 + >>> p + stim.CliffordString("I,I,I,I,I") + """ +``` + + +```python +# stim.CliffordString.__len__ + +# (in class stim.CliffordString) +def __len__( + self, +) -> int: + """Returns the number of Clifford operations in the string. + + Examples: + >>> import stim + >>> len(stim.CliffordString("I,X,Y,Z,H")) + 5 + """ +``` + + +```python +# stim.CliffordString.__mul__ + +# (in class stim.CliffordString) +def __mul__( + self, + rhs: Union[stim.CliffordString, int], +) -> stim.CliffordString: + """CliffordString multiplication. + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Examples: + >>> import stim + + >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> stim.CliffordString("I,X,H") * 3 + stim.CliffordString("I,X,H,I,X,H,I,X,H") + """ +``` + + +```python +# stim.CliffordString.__ne__ + +# (in class stim.CliffordString) +def __ne__( + self, + arg0: stim._stim_polyfill.CliffordString, +) -> bool: + """Determines if two Clifford strings have non-identical contents. + """ +``` + + +```python +# stim.CliffordString.__pow__ + +# (in class stim.CliffordString) +def __pow__( + self, + power: int, +) -> stim._stim_polyfill.CliffordString: + """Returns the CliffordString raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 returns the inverse string). + + Returns: + The Clifford string raised to the power. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**0 + stim.CliffordString("I,I,I,I,I") + + >>> p**1 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**12000001 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**2 + stim.CliffordString("I,I,I,Z,C_ZYX") + + >>> p**3 + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p**-1 + stim.CliffordString("I,X,H,S_DAG,C_ZYX") + """ +``` + + +```python +# stim.CliffordString.__repr__ + +# (in class stim.CliffordString) +def __repr__( + self, +) -> str: + """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. + """ +``` + + +```python +# stim.CliffordString.__rmul__ + +# (in class stim.CliffordString) +def __rmul__( + self, + lhs: int, +) -> stim._stim_polyfill.CliffordString: + """CliffordString left-multiplication. + + Args: + lhs: The number of times to repeat the Clifford string's contents. + + Returns: + The repeated Clifford string. + + Examples: + >>> import stim + + >>> 2 * stim.CliffordString("I,X,H") + stim.CliffordString("I,X,H,I,X,H") + + >>> 0 * stim.CliffordString("I,X,H") + stim.CliffordString("") + + >>> 5 * stim.CliffordString("I") + stim.CliffordString("I,I,I,I,I") + """ +``` + + +```python +# stim.CliffordString.__setitem__ + +# (in class stim.CliffordString) +def __setitem__( + self, + index_or_slice: Union[int, slice], + new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], +) -> None: + """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. + + Args: + index_or_slice: The index of the Clifford to overwrite, or the slice + of Cliffords to overwrite. + new_value: Specifies the value to write into the Clifford string. This can + be set to a few different types of values: + - str: Name of the single qubit Clifford gate to write to the index or + broadcast over the slice. + - stim.GateData: The single qubit Clifford gate to write to the index + or broadcast over the slice. + - stim.Tableau: Must be a single qubit tableau. Specifies the single + qubit Clifford gate to write to the index or broadcast over the + slice. + - stim.CliffordString: String of Cliffords to write into the slice. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,I,I,I,I") + + >>> s[1] = 'H' + >>> s + stim.CliffordString("I,H,I,I,I") + + >>> s[2:] = 'SQRT_X' + >>> s + stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[0] = stim.gate_data('S_DAG').inverse + >>> s + stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[:] = 'I' + >>> s + stim.CliffordString("I,I,I,I,I") + + >>> s[::2] = stim.CliffordString("X,Y,Z") + >>> s + stim.CliffordString("X,I,Y,I,Z") + + >>> s[0] = stim.Tableau.from_named_gate("H") + >>> s + stim.CliffordString("H,I,Y,I,Z") + + >>> s[:] = stim.Tableau.from_named_gate("S") + >>> s + stim.CliffordString("S,S,S,S,S") + + >>> s[:4] = stim.PauliString("IXYZ") + >>> s + stim.CliffordString("I,X,Y,Z,S") + """ +``` + + +```python +# stim.CliffordString.__str__ + +# (in class stim.CliffordString) +def __str__( + self, +) -> str: + """Returns a string representation of the CliffordString's operations. + """ +``` + + +```python +# stim.CliffordString.all_cliffords_string + +# (in class stim.CliffordString) +@staticmethod +def all_cliffords_string( +) -> stim._stim_polyfill.CliffordString: + """Returns a stim.CliffordString containing each single qubit Clifford once. + + Useful for things like testing that a method works on every single Clifford. + + Examples: + >>> import stim + >>> cliffords = stim.CliffordString.all_cliffords_string() + >>> len(cliffords) + 24 + + >>> print(cliffords[:8]) + I,X,Y,Z,H_XY,S,S_DAG,H_NXY + + >>> print(cliffords[8:16]) + H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG + + >>> print(cliffords[16:]) + C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX + """ +``` + + +```python +# stim.CliffordString.copy + +# (in class stim.CliffordString) +def copy( + self, +) -> stim._stim_polyfill.CliffordString: + """Returns a copy of the CliffordString. + + Returns: + The copy. + + Examples: + >>> import stim + >>> c = stim.CliffordString("H,X") + >>> alias = c + >>> copy = c.copy() + >>> c *= 5 + >>> alias + stim.CliffordString("H,X,H,X,H,X,H,X,H,X") + >>> copy + stim.CliffordString("H,X") + """ +``` + + +```python +# stim.CliffordString.random + +# (in class stim.CliffordString) +@staticmethod +def random( + num_qubits: int, +) -> stim._stim_polyfill.CliffordString: + """Samples a uniformly random CliffordString. + + Args: + num_qubits: The number of qubits the CliffordString should act upon. + + Examples: + >>> import stim + >>> p = stim.CliffordString.random(5) + >>> len(p) + 5 + + Returns: + The sampled Clifford string. + """ +``` + + +```python +# stim.CliffordString.x_outputs + +# (in class stim.CliffordString) +def x_outputs( + self, + *, + bit_packed_signs: bool = False, +) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates an X input into. + + For example, H conjugates X into +Z and S_DAG conjugates X into -Y. + + Combined with `z_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() + >>> x_paulis + stim.PauliString("+XXZY") + >>> x_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ +``` + + +```python +# stim.CliffordString.y_outputs + +# (in class stim.CliffordString) +def y_outputs( + self, + *, + bit_packed_signs: bool = False, +) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Y input into. + + For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() + >>> y_paulis + stim.PauliString("+YYYX") + >>> y_signs + array([False, True, True, True]) + + >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] + array([14], dtype=uint8) + """ +``` + + +```python +# stim.CliffordString.z_outputs + +# (in class stim.CliffordString) +def z_outputs( + self, + *, + bit_packed_signs: bool = False, +) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Z input into. + + For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. + + Combined with `x_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() + >>> z_paulis + stim.PauliString("+ZZXZ") + >>> z_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ +``` + ```python # stim.CompiledDemSampler @@ -5230,13 +5960,13 @@ def sample_write( shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: str = "01", + det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: str = "01", + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: str = "01", + err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: str = "01", + replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples the detector error model and writes the results to disk. @@ -5322,7 +6052,7 @@ class CompiledDetectorSampler: # (in class stim.CompiledDetectorSampler) def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, seed: object = None, ) -> None: @@ -5497,9 +6227,9 @@ def sample_write( shots: int, *, filepath: Union[str, pathlib.Path], - format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -5567,7 +6297,7 @@ class CompiledMeasurementSampler: # (in class stim.CompiledMeasurementSampler) def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -5710,8 +6440,8 @@ def sample_write( self, shots: int, *, - filepath: str, - format: str = '01', + filepath: Union[str, pathlib.Path], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -5762,7 +6492,7 @@ class CompiledMeasurementsToDetectionEventsConverter: # (in class stim.CompiledMeasurementsToDetectionEventsConverter) def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -5838,7 +6568,7 @@ def convert( *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -5937,15 +6667,15 @@ def convert( def convert_file( self, *, - measurements_filepath: str, - measurements_format: str = '01', - sweep_bits_filepath: str = None, - sweep_bits_format: str = '01', - detection_events_filepath: str, - detection_events_format: str = '01', + measurements_filepath: Union[str, pathlib.Path], + measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, + sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + detection_events_filepath: Union[str, pathlib.Path], + detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', append_observables: bool = False, - obs_out_filepath: str = None, - obs_out_format: str = '01', + obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -6032,7 +6762,7 @@ class DemInstruction: # (in class stim.DemInstruction) def __eq__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -6086,7 +6816,7 @@ def __init__( # (in class stim.DemInstruction) def __ne__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -6277,7 +7007,7 @@ class DemRepeatBlock: # (in class stim.DemRepeatBlock) def __eq__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ @@ -6291,7 +7021,7 @@ def __eq__( def __init__( self, repeat_count: int, - block: stim.DetectorErrorModel, + block: stim._stim_polyfill.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -6317,7 +7047,7 @@ def __init__( # (in class stim.DemRepeatBlock) def __ne__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -6342,7 +7072,7 @@ def __repr__( # (in class stim.DemRepeatBlock) def body_copy( self, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -6419,7 +7149,7 @@ class DemTarget: # (in class stim.DemTarget) def __eq__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -6459,7 +7189,7 @@ def __init__( # (in class stim.DemTarget) def __ne__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -6569,7 +7299,7 @@ def is_separator( @staticmethod def logical_observable_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -6599,7 +7329,7 @@ def logical_observable_id( @staticmethod def relative_detector_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -6628,7 +7358,7 @@ def relative_detector_id( # (in class stim.DemTarget) @staticmethod def separator( -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -6704,7 +7434,7 @@ class DemTargetWithCoords: # (in class stim.DemTargetWithCoords) def __init__( self, - dem_target: stim.DemTarget, + dem_target: stim._stim_polyfill.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -6758,7 +7488,7 @@ def coords( @property def dem_target( self, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -6850,8 +7580,8 @@ class DetectorErrorModel: # (in class stim.DetectorErrorModel) def __add__( self, - second: stim.DetectorErrorModel, -) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, +) -> stim._stim_polyfill.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -6877,7 +7607,7 @@ def __add__( # (in class stim.DetectorErrorModel) def __eq__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -6947,8 +7677,8 @@ def __getitem__( # (in class stim.DetectorErrorModel) def __iadd__( self, - second: stim.DetectorErrorModel, -) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, +) -> stim._stim_polyfill.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -6976,7 +7706,7 @@ def __iadd__( def __imul__( self, repetitions: int, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -7064,7 +7794,7 @@ def __len__( def __mul__( self, repetitions: int, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -7101,7 +7831,7 @@ def __mul__( # (in class stim.DetectorErrorModel) def __ne__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -7127,7 +7857,7 @@ def __repr__( def __rmul__( self, repetitions: int, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -7334,7 +8064,7 @@ def compile_sampler( self, *, seed: object = None, -) -> stim.CompiledDemSampler: +) -> stim._stim_polyfill.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -7401,7 +8131,7 @@ def compile_sampler( # (in class stim.DetectorErrorModel) def copy( self, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -7425,7 +8155,7 @@ def copy( # (in class stim.DetectorErrorModel) def diagram( self, - type: str, + type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -7486,7 +8216,7 @@ def diagram( # (in class stim.DetectorErrorModel) def flattened( self, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -7709,7 +8439,7 @@ def num_observables( def rounded( self, arg0: int, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -7752,7 +8482,7 @@ def rounded( def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -7888,7 +8618,7 @@ def to_file( # (in class stim.DetectorErrorModel) def without_tags( self, -) -> stim.DetectorErrorModel: +) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -7946,8 +8676,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim.DemTargetWithCoords], - circuit_error_locations: List[stim.CircuitErrorLocation], + dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], + circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -7983,7 +8713,7 @@ def __init__( @property def circuit_error_locations( self, -) -> List[stim.CircuitErrorLocation]: +) -> List[stim._stim_polyfill.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -8023,7 +8753,7 @@ def circuit_error_locations( @property def dem_error_terms( self, -) -> List[stim.DemTargetWithCoords]: +) -> List[stim._stim_polyfill.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ ``` @@ -9178,7 +9908,7 @@ def __init__( @property def observable( self, -) -> List[stim.GateTargetWithCoords]: +) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -9272,7 +10002,7 @@ class Flow: # (in class stim.Flow) def __eq__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -9299,7 +10029,7 @@ def __init__( the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Arguments: + Args: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -9353,8 +10083,8 @@ def __init__( # (in class stim.Flow) def __mul__( self, - rhs: stim.Flow, -) -> stim.Flow: + rhs: stim._stim_polyfill.Flow, +) -> stim._stim_polyfill.Flow: """Computes the product of two flows. Args: @@ -9387,7 +10117,7 @@ def __mul__( # (in class stim.Flow) def __ne__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -9455,7 +10185,7 @@ def included_observables_copy( # (in class stim.Flow) def input_copy( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -9497,7 +10227,7 @@ def measurements_copy( # (in class stim.Flow) def output_copy( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -9544,7 +10274,7 @@ class GateData: # (in class stim.GateData) def __eq__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -9575,7 +10305,7 @@ def __init__( # (in class stim.GateData) def __ne__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -9680,7 +10410,7 @@ def flows( @property def generalized_inverse( self, -) -> stim.GateData: +) -> stim._stim_polyfill.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -10371,7 +11101,7 @@ class GateTarget: # (in class stim.GateTarget) def __eq__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -10414,7 +11144,7 @@ def __init__( # (in class stim.GateTarget) def __ne__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -10849,7 +11579,7 @@ def coords( @property def gate_target( self, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -10887,8 +11617,8 @@ class PauliString: # (in class stim.PauliString) def __add__( self, - rhs: stim.PauliString, -) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, +) -> stim._stim_polyfill.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -10917,7 +11647,7 @@ def __add__( # (in class stim.PauliString) def __eq__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -10980,8 +11710,8 @@ def __getitem__( # (in class stim.PauliString) def __iadd__( self, - rhs: stim.PauliString, -) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, +) -> stim._stim_polyfill.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -11014,7 +11744,7 @@ def __iadd__( def __imul__( self, rhs: object, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -11064,7 +11794,7 @@ def __imul__( # (in class stim.PauliString) def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -11077,7 +11807,7 @@ def __init__( pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Arguments: + Args: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -11141,7 +11871,7 @@ def __init__( def __itruediv__( self, rhs: complex, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -11190,7 +11920,7 @@ def __len__( def __mul__( self, rhs: object, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -11248,7 +11978,7 @@ def __mul__( # (in class stim.PauliString) def __ne__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ @@ -11261,7 +11991,7 @@ def __ne__( # (in class stim.PauliString) def __neg__( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the negation of the pauli string. Examples: @@ -11282,7 +12012,7 @@ def __neg__( # (in class stim.PauliString) def __pos__( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns a pauli string with the same contents. Examples: @@ -11316,7 +12046,7 @@ def __repr__( def __rmul__( self, lhs: object, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -11425,7 +12155,7 @@ def __str__( def __truediv__( self, rhs: complex, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -11562,7 +12292,7 @@ def before( # (in class stim.PauliString) def commutes( self, - other: stim.PauliString, + other: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -11602,7 +12332,7 @@ def commutes( # (in class stim.PauliString) def copy( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -11684,7 +12414,7 @@ def from_numpy( def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -11747,7 +12477,7 @@ def iter_all( min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', -) -> stim.PauliStringIterator: +) -> stim._stim_polyfill.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -11851,7 +12581,7 @@ def random( num_qubits: int, *, allow_imaginary: bool = False, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -11972,7 +12702,7 @@ def to_numpy( # (in class stim.PauliString) def to_tableau( self, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -12023,7 +12753,7 @@ def to_tableau( def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -12104,7 +12834,7 @@ class PauliStringIterator: # (in class stim.PauliStringIterator) def __iter__( self, -) -> stim.PauliStringIterator: +) -> stim._stim_polyfill.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -12120,7 +12850,7 @@ def __iter__( # (in class stim.PauliStringIterator) def __next__( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the next iterated pauli string. """ ``` @@ -12172,8 +12902,8 @@ class Tableau: # (in class stim.Tableau) def __add__( self, - rhs: stim.Tableau, -) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, +) -> stim._stim_polyfill.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -12203,8 +12933,8 @@ def __add__( # (in class stim.Tableau) def __call__( self, - pauli_string: stim.PauliString, -) -> stim.PauliString: + pauli_string: stim._stim_polyfill.PauliString, +) -> stim._stim_polyfill.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -12242,7 +12972,7 @@ def __call__( # (in class stim.Tableau) def __eq__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ @@ -12255,8 +12985,8 @@ def __eq__( # (in class stim.Tableau) def __iadd__( self, - rhs: stim.Tableau, -) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, +) -> stim._stim_polyfill.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -12334,8 +13064,8 @@ def __len__( # (in class stim.Tableau) def __mul__( self, - rhs: stim.Tableau, -) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, +) -> stim._stim_polyfill.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -12363,7 +13093,7 @@ def __mul__( # (in class stim.Tableau) def __ne__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ @@ -12377,7 +13107,7 @@ def __ne__( def __pow__( self, exponent: int, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -12467,7 +13197,7 @@ def append( # (in class stim.Tableau) def copy( self, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -12550,9 +13280,9 @@ def from_circuit( @staticmethod def from_conjugated_generators( *, - xs: List[stim.PauliString], - zs: List[stim.PauliString], -) -> stim.Tableau: + xs: List[stim._stim_polyfill.PauliString], + zs: List[stim._stim_polyfill.PauliString], +) -> stim._stim_polyfill.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -12595,7 +13325,7 @@ def from_conjugated_generators( @staticmethod def from_named_gate( name: str, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -12826,7 +13556,7 @@ def from_stabilizers( def from_state_vector( state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -12894,7 +13624,7 @@ def from_state_vector( def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -12957,7 +13687,7 @@ def inverse( self, *, unsigned: bool = False, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -13031,7 +13761,7 @@ def inverse_x_output( input_index: int, *, unsigned: bool = False, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -13115,7 +13845,7 @@ def inverse_y_output( input_index: int, *, unsigned: bool = False, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -13199,7 +13929,7 @@ def inverse_z_output( input_index: int, *, unsigned: bool = False, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -13285,7 +14015,7 @@ def iter_all( num_qubits: int, *, unsigned: bool = False, -) -> stim.TableauIterator: +) -> stim._stim_polyfill.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -13349,7 +14079,7 @@ def prepend( @staticmethod def random( num_qubits: int, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -13376,8 +14106,8 @@ def random( # (in class stim.Tableau) def then( self, - second: stim.Tableau, -) -> stim.Tableau: + second: stim._stim_polyfill.Tableau, +) -> stim._stim_polyfill.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -13407,7 +14137,7 @@ def then( # (in class stim.Tableau) def to_circuit( self, - method: 'Literal["elimination", "graph_state"]' = 'elimination', + method: Literal["elimination", "graph_state"] = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -13708,7 +14438,7 @@ def to_numpy( # (in class stim.Tableau) def to_pauli_string( self, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -13747,7 +14477,7 @@ def to_stabilizers( self, *, canonicalize: bool = False, -) -> List[stim.PauliString]: +) -> List[stim._stim_polyfill.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -13802,7 +14532,7 @@ def to_stabilizers( def to_state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -13861,7 +14591,7 @@ def to_state_vector( def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -13913,7 +14643,7 @@ def to_unitary_matrix( def x_output( self, target: int, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -14009,7 +14739,7 @@ def x_sign( def y_output( self, target: int, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -14107,7 +14837,7 @@ def y_sign( def z_output( self, target: int, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -14221,7 +14951,7 @@ class TableauIterator: # (in class stim.TableauIterator) def __iter__( self, -) -> stim.TableauIterator: +) -> stim._stim_polyfill.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -14237,7 +14967,7 @@ def __iter__( # (in class stim.TableauIterator) def __next__( self, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Returns the next iterated tableau. """ ``` @@ -14396,7 +15126,7 @@ def c_zyx( # (in class stim.TableauSimulator) def canonical_stabilizers( self, -) -> List[stim.PauliString]: +) -> List[stim._stim_polyfill.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -14563,7 +15293,7 @@ def copy( # (in class stim.TableauSimulator) def current_inverse_tableau( self, -) -> stim.Tableau: +) -> stim._stim_polyfill.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -14809,7 +15539,7 @@ def do( # (in class stim.TableauSimulator) def do_circuit( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -14835,7 +15565,7 @@ def do_circuit( # (in class stim.TableauSimulator) def do_pauli_string( self, - pauli_string: stim.PauliString, + pauli_string: stim._stim_polyfill.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -14858,7 +15588,7 @@ def do_pauli_string( # (in class stim.TableauSimulator) def do_tableau( self, - tableau: stim.Tableau, + tableau: stim._stim_polyfill.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -15201,7 +15931,7 @@ def measure_many( # (in class stim.TableauSimulator) def measure_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -15272,7 +16002,7 @@ def num_qubits( def peek_bloch( self, target: int, -) -> stim.PauliString: +) -> stim._stim_polyfill.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -15324,7 +16054,7 @@ def peek_bloch( # (in class stim.TableauSimulator) def peek_observable_expectation( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, ) -> int: """Determines the expected value of an observable. @@ -15497,7 +16227,7 @@ def peek_z( # (in class stim.TableauSimulator) def postselect_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, desired_value: bool = False, ) -> None: @@ -15826,7 +16556,7 @@ def s_dag( # (in class stim.TableauSimulator) def set_inverse_tableau( self, - new_inverse_tableau: stim.Tableau, + new_inverse_tableau: stim._stim_polyfill.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -16003,7 +16733,7 @@ def set_state_from_state_vector( self, state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -16184,7 +16914,7 @@ def sqrt_y_dag( def state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -16812,7 +17542,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -16823,18 +17553,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -16953,7 +17683,7 @@ def target_combined_paulis( # (at top-level in the stim module) def target_combiner( -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -17009,7 +17739,7 @@ def target_inv( # (at top-level in the stim module) def target_logical_observable_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -17084,7 +17814,7 @@ def target_pauli( # (at top-level in the stim module) def target_rec( lookback_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -17118,7 +17848,7 @@ def target_rec( # (at top-level in the stim module) def target_relative_detector_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -17146,7 +17876,7 @@ def target_relative_detector_id( # (at top-level in the stim module) def target_separator( -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -17171,7 +17901,7 @@ def target_separator( # (at top-level in the stim module) def target_sweep_bit( sweep_bit_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: @@ -17296,7 +18026,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: str, + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, diff --git a/doc/stim.pyi b/doc/stim.pyi index 0f12cbc9e..8ae5519df 100644 --- a/doc/stim.pyi +++ b/doc/stim.pyi @@ -43,8 +43,8 @@ class Circuit: """ def __add__( self, - second: stim.Circuit, - ) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, + ) -> stim._stim_polyfill.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -65,7 +65,7 @@ class Circuit: """ def __eq__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -125,8 +125,8 @@ class Circuit: """ def __iadd__( self, - second: stim.Circuit, - ) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, + ) -> stim._stim_polyfill.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -149,7 +149,7 @@ class Circuit: def __imul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -222,7 +222,7 @@ class Circuit: def __mul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -252,7 +252,7 @@ class Circuit: """ def __ne__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -264,7 +264,7 @@ class Circuit: def __rmul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -490,7 +490,7 @@ class Circuit: self, *, seed: object = None, - ) -> stim.CompiledDetectorSampler: + ) -> stim._stim_polyfill.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -535,7 +535,7 @@ class Circuit: self, *, skip_reference_sample: bool = False, - ) -> stim.CompiledMeasurementsToDetectionEventsConverter: + ) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -649,7 +649,7 @@ class Circuit: """ def copy( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -761,7 +761,7 @@ class Circuit: """ def decomposed( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -961,7 +961,7 @@ class Circuit: approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1049,7 +1049,7 @@ class Circuit: """ def diagram( self, - type: str = 'timeline-text', + type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -1181,7 +1181,7 @@ class Circuit: *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1234,7 +1234,7 @@ class Circuit: """ def flattened( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -1396,7 +1396,7 @@ class Circuit: before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -1766,7 +1766,7 @@ class Circuit: """ def inverse( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2212,7 +2212,7 @@ class Circuit: dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -2370,7 +2370,7 @@ class Circuit: *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -2948,7 +2948,7 @@ class Circuit: """ def with_inlined_feedback( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3002,7 +3002,7 @@ class Circuit: """ def without_noise( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3029,7 +3029,7 @@ class Circuit: """ def without_tags( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3074,10 +3074,10 @@ class CircuitErrorLocation: self, *, tick_offset: int, - flipped_pauli_product: List[stim.GateTargetWithCoords], + flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim.CircuitTargetsInsideInstruction, - stack_frames: List[stim.CircuitErrorLocationStackFrame], + instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, + stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -3150,7 +3150,7 @@ class CircuitErrorLocation: @property def flipped_pauli_product( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -3169,7 +3169,7 @@ class CircuitErrorLocation: @property def instruction_targets( self, - ) -> stim.CircuitTargetsInsideInstruction: + ) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -3213,7 +3213,7 @@ class CircuitErrorLocation: @property def stack_frames( self, - ) -> List[stim.CircuitErrorLocationStackFrame]: + ) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -3397,7 +3397,7 @@ class CircuitInstruction: """ def __eq__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -3441,7 +3441,7 @@ class CircuitInstruction: """ def __ne__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -3559,7 +3559,7 @@ class CircuitInstruction: """ def targets_copy( self, - ) -> List[stim.GateTarget]: + ) -> List[stim._stim_polyfill.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -3596,14 +3596,14 @@ class CircuitRepeatBlock: """ def __eq__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ def __init__( self, repeat_count: int, - body: stim.Circuit, + body: stim._stim_polyfill.Circuit, *, tag: str = '', ) -> None: @@ -3627,7 +3627,7 @@ class CircuitRepeatBlock: """ def __ne__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -3638,7 +3638,7 @@ class CircuitRepeatBlock: """ def body_copy( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -3752,7 +3752,7 @@ class CircuitTargetsInsideInstruction: args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim.GateTargetWithCoords], + targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -3871,7 +3871,7 @@ class CircuitTargetsInsideInstruction: @property def targets_in_range( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -3889,6 +3889,560 @@ class CircuitTargetsInsideInstruction: >>> loc.instruction_targets.targets_in_range [stim.GateTargetWithCoords(0, [])] """ +class CliffordString: + """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). + + Represents a collection of Clifford operations applied pairwise to a + collection of qubits. Ignores global phase. + + Examples: + >>> import stim + >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") + stim.CliffordString("I,C_ZYX,SQRT_X_DAG") + """ + def __add__( + self, + rhs: stim._stim_polyfill.CliffordString, + ) -> stim._stim_polyfill.CliffordString: + """Concatenates two CliffordStrings. + + Args: + rhs: The suffix of the concatenation. + + Returns: + The concatenated Clifford string. + + Examples: + >>> import stim + >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") + stim.CliffordString("I,X,H,Y,S") + """ + def __eq__( + self, + arg0: stim._stim_polyfill.CliffordString, + ) -> bool: + """Determines if two Clifford strings have identical contents. + """ + @overload + def __getitem__( + self, + index_or_slice: int, + ) -> stim.GateData: + pass + @overload + def __getitem__( + self, + index_or_slice: slice, + ) -> stim.CliffordString: + pass + def __getitem__( + self, + index_or_slice: Union[int, slice], + ) -> Union[stim.GateData, stim.CliffordString]: + """Returns a Clifford or substring from the CliffordString. + + Args: + index_or_slice: The index of the Clifford to return, or the slice + corresponding to the sub CliffordString to return. + + Returns: + The indexed Clifford (as a stim.GateData instance) or the sliced + CliffordString. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,X,Y,Z,H") + + >>> s[2] + stim.gate_data('Y') + + >>> s[-1] + stim.gate_data('H') + + >>> s[:-1] + stim.CliffordString("I,X,Y,Z") + + >>> s[::2] + stim.CliffordString("I,Y,H") + """ + def __iadd__( + self, + rhs: stim._stim_polyfill.CliffordString, + ) -> stim._stim_polyfill.CliffordString: + """Mutates the CliffordString by concatenating onto it. + + Args: + rhs: The suffix to concatenate onto the target CliffordString. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias += stim.CliffordString("Y,S") + >>> c + stim.CliffordString("I,X,H,Y,S") + """ + def __imul__( + self, + rhs: Union[stim.CliffordString, int], + ) -> stim.CliffordString: + """Inplace CliffordString multiplication. + + Mutates the CliffordString into itself multiplied by another CliffordString + (via pairwise Clifford multipliation) or by an integer (via repeating the + contents). + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> c = stim.CliffordString("S,X,X") + >>> alias = c + >>> alias *= stim.CliffordString("S,Z,H,Z") + >>> c + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias *= 2 + >>> c + stim.CliffordString("I,X,H,I,X,H") + """ + def __init__( + self, + arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], + /, + ) -> None: + """Initializes a stim.CliffordString from the given argument. + + Args: + arg [position-only]: This can be a variety of types, including: + int: initializes an identity Clifford string of the given length. + str: initializes by parsing a comma-separated list of gate names. + stim.CliffordString: initializes by copying the given Clifford string. + stim.PauliString: initializes by copying from the given Pauli string + (ignores the sign of the Pauli string). + stim.Circuit: initializes a CliffordString equivalent to the action + of the circuit (as long as the circuit only contains single qubit + unitary operations and annotations). + Iterable: initializes by interpreting each item as a Clifford. + Each item can be a single-qubit Clifford gate name (like "SQRT_X") + or stim.GateData instance. + + Examples: + >>> import stim + + >>> stim.CliffordString(5) + stim.CliffordString("I,I,I,I,I") + + >>> stim.CliffordString("X,Y,Z,SQRT_X") + stim.CliffordString("X,Y,Z,SQRT_X") + + >>> stim.CliffordString(["H", stim.gate_data("S")]) + stim.CliffordString("H,S") + + >>> stim.CliffordString(stim.PauliString("XYZ")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.Circuit(''' + ... H 0 1 2 + ... S 2 3 + ... TICK + ... S 3 + ... I 6 + ... ''')) + stim.CliffordString("H,H,C_ZYX,Z,I,I,I") + """ + def __ipow__( + self, + num_qubits: int, + ) -> object: + """Mutates the CliffordString into itself raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 inverts the string). + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + >>> p **= 3 + >>> p + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p **= 2 + >>> p + stim.CliffordString("I,I,I,Z,I") + + >>> alias = p + >>> alias **= 2 + >>> p + stim.CliffordString("I,I,I,I,I") + """ + def __len__( + self, + ) -> int: + """Returns the number of Clifford operations in the string. + + Examples: + >>> import stim + >>> len(stim.CliffordString("I,X,Y,Z,H")) + 5 + """ + def __mul__( + self, + rhs: Union[stim.CliffordString, int], + ) -> stim.CliffordString: + """CliffordString multiplication. + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Examples: + >>> import stim + + >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> stim.CliffordString("I,X,H") * 3 + stim.CliffordString("I,X,H,I,X,H,I,X,H") + """ + def __ne__( + self, + arg0: stim._stim_polyfill.CliffordString, + ) -> bool: + """Determines if two Clifford strings have non-identical contents. + """ + def __pow__( + self, + power: int, + ) -> stim._stim_polyfill.CliffordString: + """Returns the CliffordString raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 returns the inverse string). + + Returns: + The Clifford string raised to the power. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**0 + stim.CliffordString("I,I,I,I,I") + + >>> p**1 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**12000001 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**2 + stim.CliffordString("I,I,I,Z,C_ZYX") + + >>> p**3 + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p**-1 + stim.CliffordString("I,X,H,S_DAG,C_ZYX") + """ + def __repr__( + self, + ) -> str: + """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. + """ + def __rmul__( + self, + lhs: int, + ) -> stim._stim_polyfill.CliffordString: + """CliffordString left-multiplication. + + Args: + lhs: The number of times to repeat the Clifford string's contents. + + Returns: + The repeated Clifford string. + + Examples: + >>> import stim + + >>> 2 * stim.CliffordString("I,X,H") + stim.CliffordString("I,X,H,I,X,H") + + >>> 0 * stim.CliffordString("I,X,H") + stim.CliffordString("") + + >>> 5 * stim.CliffordString("I") + stim.CliffordString("I,I,I,I,I") + """ + def __setitem__( + self, + index_or_slice: Union[int, slice], + new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], + ) -> None: + """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. + + Args: + index_or_slice: The index of the Clifford to overwrite, or the slice + of Cliffords to overwrite. + new_value: Specifies the value to write into the Clifford string. This can + be set to a few different types of values: + - str: Name of the single qubit Clifford gate to write to the index or + broadcast over the slice. + - stim.GateData: The single qubit Clifford gate to write to the index + or broadcast over the slice. + - stim.Tableau: Must be a single qubit tableau. Specifies the single + qubit Clifford gate to write to the index or broadcast over the + slice. + - stim.CliffordString: String of Cliffords to write into the slice. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,I,I,I,I") + + >>> s[1] = 'H' + >>> s + stim.CliffordString("I,H,I,I,I") + + >>> s[2:] = 'SQRT_X' + >>> s + stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[0] = stim.gate_data('S_DAG').inverse + >>> s + stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[:] = 'I' + >>> s + stim.CliffordString("I,I,I,I,I") + + >>> s[::2] = stim.CliffordString("X,Y,Z") + >>> s + stim.CliffordString("X,I,Y,I,Z") + + >>> s[0] = stim.Tableau.from_named_gate("H") + >>> s + stim.CliffordString("H,I,Y,I,Z") + + >>> s[:] = stim.Tableau.from_named_gate("S") + >>> s + stim.CliffordString("S,S,S,S,S") + + >>> s[:4] = stim.PauliString("IXYZ") + >>> s + stim.CliffordString("I,X,Y,Z,S") + """ + def __str__( + self, + ) -> str: + """Returns a string representation of the CliffordString's operations. + """ + @staticmethod + def all_cliffords_string( + ) -> stim._stim_polyfill.CliffordString: + """Returns a stim.CliffordString containing each single qubit Clifford once. + + Useful for things like testing that a method works on every single Clifford. + + Examples: + >>> import stim + >>> cliffords = stim.CliffordString.all_cliffords_string() + >>> len(cliffords) + 24 + + >>> print(cliffords[:8]) + I,X,Y,Z,H_XY,S,S_DAG,H_NXY + + >>> print(cliffords[8:16]) + H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG + + >>> print(cliffords[16:]) + C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX + """ + def copy( + self, + ) -> stim._stim_polyfill.CliffordString: + """Returns a copy of the CliffordString. + + Returns: + The copy. + + Examples: + >>> import stim + >>> c = stim.CliffordString("H,X") + >>> alias = c + >>> copy = c.copy() + >>> c *= 5 + >>> alias + stim.CliffordString("H,X,H,X,H,X,H,X,H,X") + >>> copy + stim.CliffordString("H,X") + """ + @staticmethod + def random( + num_qubits: int, + ) -> stim._stim_polyfill.CliffordString: + """Samples a uniformly random CliffordString. + + Args: + num_qubits: The number of qubits the CliffordString should act upon. + + Examples: + >>> import stim + >>> p = stim.CliffordString.random(5) + >>> len(p) + 5 + + Returns: + The sampled Clifford string. + """ + def x_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates an X input into. + + For example, H conjugates X into +Z and S_DAG conjugates X into -Y. + + Combined with `z_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() + >>> x_paulis + stim.PauliString("+XXZY") + >>> x_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ + def y_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Y input into. + + For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() + >>> y_paulis + stim.PauliString("+YYYX") + >>> y_signs + array([False, True, True, True]) + + >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] + array([14], dtype=uint8) + """ + def z_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Z input into. + + For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. + + Combined with `x_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() + >>> z_paulis + stim.PauliString("+ZZXZ") + >>> z_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ class CompiledDemSampler: """A helper class for efficiently sampler from a detector error model. @@ -4073,13 +4627,13 @@ class CompiledDemSampler: shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: str = "01", + det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: str = "01", + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: str = "01", + err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: str = "01", + replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples the detector error model and writes the results to disk. @@ -4151,7 +4705,7 @@ class CompiledDetectorSampler: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, seed: object = None, ) -> None: @@ -4333,9 +4887,9 @@ class CompiledDetectorSampler: shots: int, *, filepath: Union[str, pathlib.Path], - format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -4389,7 +4943,7 @@ class CompiledMeasurementSampler: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -4539,8 +5093,8 @@ class CompiledMeasurementSampler: self, shots: int, *, - filepath: str, - format: str = '01', + filepath: Union[str, pathlib.Path], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -4577,7 +5131,7 @@ class CompiledMeasurementsToDetectionEventsConverter: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -4639,7 +5193,7 @@ class CompiledMeasurementsToDetectionEventsConverter: *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -4731,15 +5285,15 @@ class CompiledMeasurementsToDetectionEventsConverter: def convert_file( self, *, - measurements_filepath: str, - measurements_format: str = '01', - sweep_bits_filepath: str = None, - sweep_bits_format: str = '01', - detection_events_filepath: str, - detection_events_format: str = '01', + measurements_filepath: Union[str, pathlib.Path], + measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, + sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + detection_events_filepath: Union[str, pathlib.Path], + detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', append_observables: bool = False, - obs_out_filepath: str = None, - obs_out_format: str = '01', + obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -4812,7 +5366,7 @@ class DemInstruction: """ def __eq__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -4852,7 +5406,7 @@ class DemInstruction: """ def __ne__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -4980,14 +5534,14 @@ class DemRepeatBlock: """ def __eq__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ def __init__( self, repeat_count: int, - block: stim.DetectorErrorModel, + block: stim._stim_polyfill.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -5006,7 +5560,7 @@ class DemRepeatBlock: """ def __ne__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -5017,7 +5571,7 @@ class DemRepeatBlock: """ def body_copy( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -5066,7 +5620,7 @@ class DemTarget: """ def __eq__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -5092,7 +5646,7 @@ class DemTarget: """ def __ne__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -5160,7 +5714,7 @@ class DemTarget: @staticmethod def logical_observable_id( index: int, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -5183,7 +5737,7 @@ class DemTarget: @staticmethod def relative_detector_id( index: int, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -5205,7 +5759,7 @@ class DemTarget: """ @staticmethod def separator( - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -5260,7 +5814,7 @@ class DemTargetWithCoords: """ def __init__( self, - dem_target: stim.DemTarget, + dem_target: stim._stim_polyfill.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -5300,7 +5854,7 @@ class DemTargetWithCoords: @property def dem_target( self, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -5378,8 +5932,8 @@ class DetectorErrorModel: """ def __add__( self, - second: stim.DetectorErrorModel, - ) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, + ) -> stim._stim_polyfill.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -5398,7 +5952,7 @@ class DetectorErrorModel: """ def __eq__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -5454,8 +6008,8 @@ class DetectorErrorModel: """ def __iadd__( self, - second: stim.DetectorErrorModel, - ) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, + ) -> stim._stim_polyfill.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -5476,7 +6030,7 @@ class DetectorErrorModel: def __imul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -5543,7 +6097,7 @@ class DetectorErrorModel: def __mul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -5573,7 +6127,7 @@ class DetectorErrorModel: """ def __ne__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -5585,7 +6139,7 @@ class DetectorErrorModel: def __rmul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -5757,7 +6311,7 @@ class DetectorErrorModel: self, *, seed: object = None, - ) -> stim.CompiledDemSampler: + ) -> stim._stim_polyfill.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -5817,7 +6371,7 @@ class DetectorErrorModel: """ def copy( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -5834,7 +6388,7 @@ class DetectorErrorModel: """ def diagram( self, - type: str, + type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -5888,7 +6442,7 @@ class DetectorErrorModel: """ def flattened( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -6069,7 +6623,7 @@ class DetectorErrorModel: def rounded( self, arg0: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -6105,7 +6659,7 @@ class DetectorErrorModel: def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -6227,7 +6781,7 @@ class DetectorErrorModel: """ def without_tags( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -6271,8 +6825,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim.DemTargetWithCoords], - circuit_error_locations: List[stim.CircuitErrorLocation], + dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], + circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -6301,7 +6855,7 @@ class ExplainedError: @property def circuit_error_locations( self, - ) -> List[stim.CircuitErrorLocation]: + ) -> List[stim._stim_polyfill.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -6334,7 +6888,7 @@ class ExplainedError: @property def dem_error_terms( self, - ) -> List[stim.DemTargetWithCoords]: + ) -> List[stim._stim_polyfill.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ class FlipSimulator: @@ -7335,7 +7889,7 @@ class FlippedMeasurement: @property def observable( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -7408,7 +7962,7 @@ class Flow: """ def __eq__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -7428,7 +7982,7 @@ class Flow: the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Arguments: + Args: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -7475,8 +8029,8 @@ class Flow: """ def __mul__( self, - rhs: stim.Flow, - ) -> stim.Flow: + rhs: stim._stim_polyfill.Flow, + ) -> stim._stim_polyfill.Flow: """Computes the product of two flows. Args: @@ -7502,7 +8056,7 @@ class Flow: """ def __ne__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -7542,7 +8096,7 @@ class Flow: """ def input_copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -7570,7 +8124,7 @@ class Flow: """ def output_copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -7603,7 +8157,7 @@ class GateData: """ def __eq__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -7620,7 +8174,7 @@ class GateData: """ def __ne__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -7690,7 +8244,7 @@ class GateData: @property def generalized_inverse( self, - ) -> stim.GateData: + ) -> stim._stim_polyfill.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -8262,7 +8816,7 @@ class GateTarget: """ def __eq__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -8291,7 +8845,7 @@ class GateTarget: """ def __ne__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -8614,7 +9168,7 @@ class GateTargetWithCoords: @property def gate_target( self, - ) -> stim.GateTarget: + ) -> stim._stim_polyfill.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -8638,8 +9192,8 @@ class PauliString: """ def __add__( self, - rhs: stim.PauliString, - ) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -8661,7 +9215,7 @@ class PauliString: """ def __eq__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -8710,8 +9264,8 @@ class PauliString: """ def __iadd__( self, - rhs: stim.PauliString, - ) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -8737,7 +9291,7 @@ class PauliString: def __imul__( self, rhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -8780,7 +9334,7 @@ class PauliString: """ def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -8793,7 +9347,7 @@ class PauliString: pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Arguments: + Args: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -8850,7 +9404,7 @@ class PauliString: def __itruediv__( self, rhs: complex, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -8885,7 +9439,7 @@ class PauliString: def __mul__( self, rhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -8936,13 +9490,13 @@ class PauliString: """ def __ne__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ def __neg__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the negation of the pauli string. Examples: @@ -8956,7 +9510,7 @@ class PauliString: """ def __pos__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a pauli string with the same contents. Examples: @@ -8976,7 +9530,7 @@ class PauliString: def __rmul__( self, lhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9064,7 +9618,7 @@ class PauliString: def __truediv__( self, rhs: complex, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -9180,7 +9734,7 @@ class PauliString: """ def commutes( self, - other: stim.PauliString, + other: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -9213,7 +9767,7 @@ class PauliString: """ def copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -9229,8 +9783,8 @@ class PauliString: """ def extended_product( self, - other: stim.PauliString, - ) -> Tuple[complex, stim.PauliString]: + other: stim._stim_polyfill.PauliString, + ) -> Tuple[complex, stim._stim_polyfill.PauliString]: """[DEPRECATED] Use multiplication (__mul__ or *) instead. """ @staticmethod @@ -9287,7 +9841,7 @@ class PauliString: def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -9343,7 +9897,7 @@ class PauliString: min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', - ) -> stim.PauliStringIterator: + ) -> stim._stim_polyfill.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -9433,7 +9987,7 @@ class PauliString: num_qubits: int, *, allow_imaginary: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -9533,7 +10087,7 @@ class PauliString: """ def to_tableau( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -9577,7 +10131,7 @@ class PauliString: def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -9637,7 +10191,7 @@ class PauliStringIterator: """ def __iter__( self, - ) -> stim.PauliStringIterator: + ) -> stim._stim_polyfill.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -9646,7 +10200,7 @@ class PauliStringIterator: """ def __next__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the next iterated pauli string. """ class Tableau: @@ -9684,8 +10238,8 @@ class Tableau: """ def __add__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -9708,8 +10262,8 @@ class Tableau: """ def __call__( self, - pauli_string: stim.PauliString, - ) -> stim.PauliString: + pauli_string: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -9740,14 +10294,14 @@ class Tableau: """ def __eq__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ def __iadd__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -9804,8 +10358,8 @@ class Tableau: """ def __mul__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -9826,14 +10380,14 @@ class Tableau: """ def __ne__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ def __pow__( self, exponent: int, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -9895,7 +10449,7 @@ class Tableau: """ def copy( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -9964,9 +10518,9 @@ class Tableau: @staticmethod def from_conjugated_generators( *, - xs: List[stim.PauliString], - zs: List[stim.PauliString], - ) -> stim.Tableau: + xs: List[stim._stim_polyfill.PauliString], + zs: List[stim._stim_polyfill.PauliString], + ) -> stim._stim_polyfill.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -10002,7 +10556,7 @@ class Tableau: @staticmethod def from_named_gate( name: str, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -10212,7 +10766,7 @@ class Tableau: def from_state_vector( state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -10273,7 +10827,7 @@ class Tableau: def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -10329,7 +10883,7 @@ class Tableau: self, *, unsigned: bool = False, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -10396,7 +10950,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -10466,7 +11020,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -10536,7 +11090,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -10608,7 +11162,7 @@ class Tableau: num_qubits: int, *, unsigned: bool = False, - ) -> stim.TableauIterator: + ) -> stim._stim_polyfill.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -10658,7 +11212,7 @@ class Tableau: @staticmethod def random( num_qubits: int, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -10678,8 +11232,8 @@ class Tableau: """ def then( self, - second: stim.Tableau, - ) -> stim.Tableau: + second: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -10702,7 +11256,7 @@ class Tableau: """ def to_circuit( self, - method: 'Literal["elimination", "graph_state"]' = 'elimination', + method: Literal["elimination", "graph_state"] = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -10989,7 +11543,7 @@ class Tableau: """ def to_pauli_string( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -11021,7 +11575,7 @@ class Tableau: self, *, canonicalize: bool = False, - ) -> List[stim.PauliString]: + ) -> List[stim._stim_polyfill.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -11069,7 +11623,7 @@ class Tableau: def to_state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -11121,7 +11675,7 @@ class Tableau: def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -11166,7 +11720,7 @@ class Tableau: def x_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -11241,7 +11795,7 @@ class Tableau: def y_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -11318,7 +11872,7 @@ class Tableau: def z_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -11404,7 +11958,7 @@ class TableauIterator: """ def __iter__( self, - ) -> stim.TableauIterator: + ) -> stim._stim_polyfill.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -11413,7 +11967,7 @@ class TableauIterator: """ def __next__( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns the next iterated tableau. """ class TableauSimulator: @@ -11537,7 +12091,7 @@ class TableauSimulator: """ def canonical_stabilizers( self, - ) -> List[stim.PauliString]: + ) -> List[stim._stim_polyfill.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -11683,7 +12237,7 @@ class TableauSimulator: """ def current_inverse_tableau( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -11873,7 +12427,7 @@ class TableauSimulator: """ def do_circuit( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -11892,7 +12446,7 @@ class TableauSimulator: """ def do_pauli_string( self, - pauli_string: stim.PauliString, + pauli_string: stim._stim_polyfill.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -11908,7 +12462,7 @@ class TableauSimulator: """ def do_tableau( self, - tableau: stim.Tableau, + tableau: stim._stim_polyfill.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -12181,7 +12735,7 @@ class TableauSimulator: """ def measure_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -12238,7 +12792,7 @@ class TableauSimulator: def peek_bloch( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -12283,7 +12837,7 @@ class TableauSimulator: """ def peek_observable_expectation( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, ) -> int: """Determines the expected value of an observable. @@ -12428,7 +12982,7 @@ class TableauSimulator: """ def postselect_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, desired_value: bool = False, ) -> None: @@ -12687,7 +13241,7 @@ class TableauSimulator: """ def set_inverse_tableau( self, - new_inverse_tableau: stim.Tableau, + new_inverse_tableau: stim._stim_polyfill.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -12843,7 +13397,7 @@ class TableauSimulator: self, state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -12989,7 +13543,7 @@ class TableauSimulator: def state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -13484,7 +14038,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -13495,18 +14049,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -13611,7 +14165,7 @@ def target_combined_paulis( ''') """ def target_combiner( -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -13653,7 +14207,7 @@ def target_inv( """ def target_logical_observable_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -13714,7 +14268,7 @@ def target_pauli( """ def target_rec( lookback_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -13741,7 +14295,7 @@ def target_rec( """ def target_relative_detector_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -13762,7 +14316,7 @@ def target_relative_detector_id( ''') """ def target_separator( -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -13780,7 +14334,7 @@ def target_separator( """ def target_sweep_bit( sweep_bit_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: @@ -13877,7 +14431,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: str, + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, diff --git a/glue/python/src/stim/__init__.pyi b/glue/python/src/stim/__init__.pyi index 0f12cbc9e..8ae5519df 100644 --- a/glue/python/src/stim/__init__.pyi +++ b/glue/python/src/stim/__init__.pyi @@ -43,8 +43,8 @@ class Circuit: """ def __add__( self, - second: stim.Circuit, - ) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, + ) -> stim._stim_polyfill.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -65,7 +65,7 @@ class Circuit: """ def __eq__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -125,8 +125,8 @@ class Circuit: """ def __iadd__( self, - second: stim.Circuit, - ) -> stim.Circuit: + second: stim._stim_polyfill.Circuit, + ) -> stim._stim_polyfill.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -149,7 +149,7 @@ class Circuit: def __imul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -222,7 +222,7 @@ class Circuit: def __mul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -252,7 +252,7 @@ class Circuit: """ def __ne__( self, - arg0: stim.Circuit, + arg0: stim._stim_polyfill.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -264,7 +264,7 @@ class Circuit: def __rmul__( self, repetitions: int, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -490,7 +490,7 @@ class Circuit: self, *, seed: object = None, - ) -> stim.CompiledDetectorSampler: + ) -> stim._stim_polyfill.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -535,7 +535,7 @@ class Circuit: self, *, skip_reference_sample: bool = False, - ) -> stim.CompiledMeasurementsToDetectionEventsConverter: + ) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -649,7 +649,7 @@ class Circuit: """ def copy( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -761,7 +761,7 @@ class Circuit: """ def decomposed( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -961,7 +961,7 @@ class Circuit: approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1049,7 +1049,7 @@ class Circuit: """ def diagram( self, - type: str = 'timeline-text', + type: Literal["timeline-text", "timeline-svg", "timeline-svg-html", "timeline-3d", "timeline-3d-html", "detslice-text", "detslice-svg", "detslice-svg-html", "matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html", "timeslice-svg", "timeslice-svg-html", "detslice-with-ops-svg", "detslice-with-ops-svg-html", "interactive", "interactive-html"] = 'timeline-text', *, tick: Union[None, int, range] = None, filter_coords: Iterable[Union[Iterable[float], stim.DemTarget]] = ((),), @@ -1181,7 +1181,7 @@ class Circuit: *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1234,7 +1234,7 @@ class Circuit: """ def flattened( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -1396,7 +1396,7 @@ class Circuit: before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -1766,7 +1766,7 @@ class Circuit: """ def inverse( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2212,7 +2212,7 @@ class Circuit: dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -2370,7 +2370,7 @@ class Circuit: *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, - ) -> List[stim.ExplainedError]: + ) -> List[stim._stim_polyfill.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -2948,7 +2948,7 @@ class Circuit: """ def with_inlined_feedback( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3002,7 +3002,7 @@ class Circuit: """ def without_noise( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3029,7 +3029,7 @@ class Circuit: """ def without_tags( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3074,10 +3074,10 @@ class CircuitErrorLocation: self, *, tick_offset: int, - flipped_pauli_product: List[stim.GateTargetWithCoords], + flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim.CircuitTargetsInsideInstruction, - stack_frames: List[stim.CircuitErrorLocationStackFrame], + instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, + stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -3150,7 +3150,7 @@ class CircuitErrorLocation: @property def flipped_pauli_product( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -3169,7 +3169,7 @@ class CircuitErrorLocation: @property def instruction_targets( self, - ) -> stim.CircuitTargetsInsideInstruction: + ) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -3213,7 +3213,7 @@ class CircuitErrorLocation: @property def stack_frames( self, - ) -> List[stim.CircuitErrorLocationStackFrame]: + ) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -3397,7 +3397,7 @@ class CircuitInstruction: """ def __eq__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -3441,7 +3441,7 @@ class CircuitInstruction: """ def __ne__( self, - arg0: stim.CircuitInstruction, + arg0: stim._stim_polyfill.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -3559,7 +3559,7 @@ class CircuitInstruction: """ def targets_copy( self, - ) -> List[stim.GateTarget]: + ) -> List[stim._stim_polyfill.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -3596,14 +3596,14 @@ class CircuitRepeatBlock: """ def __eq__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ def __init__( self, repeat_count: int, - body: stim.Circuit, + body: stim._stim_polyfill.Circuit, *, tag: str = '', ) -> None: @@ -3627,7 +3627,7 @@ class CircuitRepeatBlock: """ def __ne__( self, - arg0: stim.CircuitRepeatBlock, + arg0: stim._stim_polyfill.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -3638,7 +3638,7 @@ class CircuitRepeatBlock: """ def body_copy( self, - ) -> stim.Circuit: + ) -> stim._stim_polyfill.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -3752,7 +3752,7 @@ class CircuitTargetsInsideInstruction: args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim.GateTargetWithCoords], + targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -3871,7 +3871,7 @@ class CircuitTargetsInsideInstruction: @property def targets_in_range( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -3889,6 +3889,560 @@ class CircuitTargetsInsideInstruction: >>> loc.instruction_targets.targets_in_range [stim.GateTargetWithCoords(0, [])] """ +class CliffordString: + """A tensor product of single qubit Clifford gates (e.g. "H \u2297 X \u2297 S"). + + Represents a collection of Clifford operations applied pairwise to a + collection of qubits. Ignores global phase. + + Examples: + >>> import stim + >>> stim.CliffordString("H,S,C_XYZ") * stim.CliffordString("H,H,H") + stim.CliffordString("I,C_ZYX,SQRT_X_DAG") + """ + def __add__( + self, + rhs: stim._stim_polyfill.CliffordString, + ) -> stim._stim_polyfill.CliffordString: + """Concatenates two CliffordStrings. + + Args: + rhs: The suffix of the concatenation. + + Returns: + The concatenated Clifford string. + + Examples: + >>> import stim + >>> stim.CliffordString("I,X,H") + stim.CliffordString("Y,S") + stim.CliffordString("I,X,H,Y,S") + """ + def __eq__( + self, + arg0: stim._stim_polyfill.CliffordString, + ) -> bool: + """Determines if two Clifford strings have identical contents. + """ + @overload + def __getitem__( + self, + index_or_slice: int, + ) -> stim.GateData: + pass + @overload + def __getitem__( + self, + index_or_slice: slice, + ) -> stim.CliffordString: + pass + def __getitem__( + self, + index_or_slice: Union[int, slice], + ) -> Union[stim.GateData, stim.CliffordString]: + """Returns a Clifford or substring from the CliffordString. + + Args: + index_or_slice: The index of the Clifford to return, or the slice + corresponding to the sub CliffordString to return. + + Returns: + The indexed Clifford (as a stim.GateData instance) or the sliced + CliffordString. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,X,Y,Z,H") + + >>> s[2] + stim.gate_data('Y') + + >>> s[-1] + stim.gate_data('H') + + >>> s[:-1] + stim.CliffordString("I,X,Y,Z") + + >>> s[::2] + stim.CliffordString("I,Y,H") + """ + def __iadd__( + self, + rhs: stim._stim_polyfill.CliffordString, + ) -> stim._stim_polyfill.CliffordString: + """Mutates the CliffordString by concatenating onto it. + + Args: + rhs: The suffix to concatenate onto the target CliffordString. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias += stim.CliffordString("Y,S") + >>> c + stim.CliffordString("I,X,H,Y,S") + """ + def __imul__( + self, + rhs: Union[stim.CliffordString, int], + ) -> stim.CliffordString: + """Inplace CliffordString multiplication. + + Mutates the CliffordString into itself multiplied by another CliffordString + (via pairwise Clifford multipliation) or by an integer (via repeating the + contents). + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> c = stim.CliffordString("S,X,X") + >>> alias = c + >>> alias *= stim.CliffordString("S,Z,H,Z") + >>> c + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> c = stim.CliffordString("I,X,H") + >>> alias = c + >>> alias *= 2 + >>> c + stim.CliffordString("I,X,H,I,X,H") + """ + def __init__( + self, + arg: Union[int, str, stim.CliffordString, stim.PauliString, stim.Circuit], + /, + ) -> None: + """Initializes a stim.CliffordString from the given argument. + + Args: + arg [position-only]: This can be a variety of types, including: + int: initializes an identity Clifford string of the given length. + str: initializes by parsing a comma-separated list of gate names. + stim.CliffordString: initializes by copying the given Clifford string. + stim.PauliString: initializes by copying from the given Pauli string + (ignores the sign of the Pauli string). + stim.Circuit: initializes a CliffordString equivalent to the action + of the circuit (as long as the circuit only contains single qubit + unitary operations and annotations). + Iterable: initializes by interpreting each item as a Clifford. + Each item can be a single-qubit Clifford gate name (like "SQRT_X") + or stim.GateData instance. + + Examples: + >>> import stim + + >>> stim.CliffordString(5) + stim.CliffordString("I,I,I,I,I") + + >>> stim.CliffordString("X,Y,Z,SQRT_X") + stim.CliffordString("X,Y,Z,SQRT_X") + + >>> stim.CliffordString(["H", stim.gate_data("S")]) + stim.CliffordString("H,S") + + >>> stim.CliffordString(stim.PauliString("XYZ")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.CliffordString("X,Y,Z")) + stim.CliffordString("X,Y,Z") + + >>> stim.CliffordString(stim.Circuit(''' + ... H 0 1 2 + ... S 2 3 + ... TICK + ... S 3 + ... I 6 + ... ''')) + stim.CliffordString("H,H,C_ZYX,Z,I,I,I") + """ + def __ipow__( + self, + num_qubits: int, + ) -> object: + """Mutates the CliffordString into itself raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 inverts the string). + + Returns: + The mutated Clifford string. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + >>> p **= 3 + >>> p + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p **= 2 + >>> p + stim.CliffordString("I,I,I,Z,I") + + >>> alias = p + >>> alias **= 2 + >>> p + stim.CliffordString("I,I,I,I,I") + """ + def __len__( + self, + ) -> int: + """Returns the number of Clifford operations in the string. + + Examples: + >>> import stim + >>> len(stim.CliffordString("I,X,Y,Z,H")) + 5 + """ + def __mul__( + self, + rhs: Union[stim.CliffordString, int], + ) -> stim.CliffordString: + """CliffordString multiplication. + + Args: + rhs: Either a stim.CliffordString or an int. If rhs is a + stim.CliffordString, then the Cliffords from each string are multiplied + pairwise. If rhs is an int, it is the number of times to repeat the + Clifford string's contents. + + Examples: + >>> import stim + + >>> stim.CliffordString("S,X,X") * stim.CliffordString("S,Z,H,Z") + stim.CliffordString("Z,Y,SQRT_Y,Z") + + >>> stim.CliffordString("I,X,H") * 3 + stim.CliffordString("I,X,H,I,X,H,I,X,H") + """ + def __ne__( + self, + arg0: stim._stim_polyfill.CliffordString, + ) -> bool: + """Determines if two Clifford strings have non-identical contents. + """ + def __pow__( + self, + power: int, + ) -> stim._stim_polyfill.CliffordString: + """Returns the CliffordString raised to a power. + + Args: + power: The power to raise the CliffordString's Cliffords to. + This value can be negative (e.g. -1 returns the inverse string). + + Returns: + The Clifford string raised to the power. + + Examples: + >>> import stim + + >>> p = stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**0 + stim.CliffordString("I,I,I,I,I") + + >>> p**1 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**12000001 + stim.CliffordString("I,X,H,S,C_XYZ") + + >>> p**2 + stim.CliffordString("I,I,I,Z,C_ZYX") + + >>> p**3 + stim.CliffordString("I,X,H,S_DAG,I") + + >>> p**-1 + stim.CliffordString("I,X,H,S_DAG,C_ZYX") + """ + def __repr__( + self, + ) -> str: + """Returns text that is a valid python expression evaluating to an equivalent `stim.CliffordString`. + """ + def __rmul__( + self, + lhs: int, + ) -> stim._stim_polyfill.CliffordString: + """CliffordString left-multiplication. + + Args: + lhs: The number of times to repeat the Clifford string's contents. + + Returns: + The repeated Clifford string. + + Examples: + >>> import stim + + >>> 2 * stim.CliffordString("I,X,H") + stim.CliffordString("I,X,H,I,X,H") + + >>> 0 * stim.CliffordString("I,X,H") + stim.CliffordString("") + + >>> 5 * stim.CliffordString("I") + stim.CliffordString("I,I,I,I,I") + """ + def __setitem__( + self, + index_or_slice: Union[int, slice], + new_value: Union[str, stim.GateData, stim.CliffordString, stim.PauliString, stim.Tableau], + ) -> None: + """Overwrites an indexed Clifford, or slice of Cliffords, with the given value. + + Args: + index_or_slice: The index of the Clifford to overwrite, or the slice + of Cliffords to overwrite. + new_value: Specifies the value to write into the Clifford string. This can + be set to a few different types of values: + - str: Name of the single qubit Clifford gate to write to the index or + broadcast over the slice. + - stim.GateData: The single qubit Clifford gate to write to the index + or broadcast over the slice. + - stim.Tableau: Must be a single qubit tableau. Specifies the single + qubit Clifford gate to write to the index or broadcast over the + slice. + - stim.CliffordString: String of Cliffords to write into the slice. + + Examples: + >>> import stim + >>> s = stim.CliffordString("I,I,I,I,I") + + >>> s[1] = 'H' + >>> s + stim.CliffordString("I,H,I,I,I") + + >>> s[2:] = 'SQRT_X' + >>> s + stim.CliffordString("I,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[0] = stim.gate_data('S_DAG').inverse + >>> s + stim.CliffordString("S,H,SQRT_X,SQRT_X,SQRT_X") + + >>> s[:] = 'I' + >>> s + stim.CliffordString("I,I,I,I,I") + + >>> s[::2] = stim.CliffordString("X,Y,Z") + >>> s + stim.CliffordString("X,I,Y,I,Z") + + >>> s[0] = stim.Tableau.from_named_gate("H") + >>> s + stim.CliffordString("H,I,Y,I,Z") + + >>> s[:] = stim.Tableau.from_named_gate("S") + >>> s + stim.CliffordString("S,S,S,S,S") + + >>> s[:4] = stim.PauliString("IXYZ") + >>> s + stim.CliffordString("I,X,Y,Z,S") + """ + def __str__( + self, + ) -> str: + """Returns a string representation of the CliffordString's operations. + """ + @staticmethod + def all_cliffords_string( + ) -> stim._stim_polyfill.CliffordString: + """Returns a stim.CliffordString containing each single qubit Clifford once. + + Useful for things like testing that a method works on every single Clifford. + + Examples: + >>> import stim + >>> cliffords = stim.CliffordString.all_cliffords_string() + >>> len(cliffords) + 24 + + >>> print(cliffords[:8]) + I,X,Y,Z,H_XY,S,S_DAG,H_NXY + + >>> print(cliffords[8:16]) + H,SQRT_Y_DAG,H_NXZ,SQRT_Y,H_YZ,H_NYZ,SQRT_X,SQRT_X_DAG + + >>> print(cliffords[16:]) + C_XYZ,C_XYNZ,C_NXYZ,C_XNYZ,C_ZYX,C_ZNYX,C_NZYX,C_ZYNX + """ + def copy( + self, + ) -> stim._stim_polyfill.CliffordString: + """Returns a copy of the CliffordString. + + Returns: + The copy. + + Examples: + >>> import stim + >>> c = stim.CliffordString("H,X") + >>> alias = c + >>> copy = c.copy() + >>> c *= 5 + >>> alias + stim.CliffordString("H,X,H,X,H,X,H,X,H,X") + >>> copy + stim.CliffordString("H,X") + """ + @staticmethod + def random( + num_qubits: int, + ) -> stim._stim_polyfill.CliffordString: + """Samples a uniformly random CliffordString. + + Args: + num_qubits: The number of qubits the CliffordString should act upon. + + Examples: + >>> import stim + >>> p = stim.CliffordString.random(5) + >>> len(p) + 5 + + Returns: + The sampled Clifford string. + """ + def x_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates an X input into. + + For example, H conjugates X into +Z and S_DAG conjugates X into -Y. + + Combined with `z_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> x_paulis, x_signs = stim.CliffordString("I,Y,H,S").x_outputs() + >>> x_paulis + stim.PauliString("+XXZY") + >>> x_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").x_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ + def y_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Y input into. + + For example, H conjugates Y into -Y and S_DAG conjugates Y into +X. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> y_paulis, y_signs = stim.CliffordString("I,X,H,S").y_outputs() + >>> y_paulis + stim.PauliString("+YYYX") + >>> y_signs + array([False, True, True, True]) + + >>> stim.CliffordString("I,X,H,S").y_outputs(bit_packed_signs=True)[1] + array([14], dtype=uint8) + """ + def z_outputs( + self, + *, + bit_packed_signs: bool = False, + ) -> Tuple[stim.PauliString, np.ndarray]: + """Returns what each Clifford in the CliffordString conjugates a Z input into. + + For example, H conjugates Z into +X and SQRT_X conjugates Z into -Y. + + Combined with `x_outputs`, the results of this method completely specify + the single qubit Clifford applied to each qubit. + + Args: + bit_packed_signs: Defaults to False. When False, the sign data is returned + in a numpy array with dtype `np.bool_`. When True, the dtype is instead + `np.uint8` and 8 bits are packed into each byte (in little endian + order). + + Returns: + A (paulis, signs) tuple. + + `paulis` has type stim.PauliString. Its sign is always positive. + + `signs` has type np.ndarray and an argument-dependent shape: + bit_packed_signs=False: + dtype=np.bool_ + shape=(num_qubits,) + bit_packed_signs=True: + dtype=np.uint8 + shape=(math.ceil(num_qubits / 8),) + + Examples: + >>> import stim + >>> z_paulis, z_signs = stim.CliffordString("I,Y,H,S").z_outputs() + >>> z_paulis + stim.PauliString("+ZZXZ") + >>> z_signs + array([False, True, False, False]) + + >>> stim.CliffordString("I,Y,H,S").z_outputs(bit_packed_signs=True)[1] + array([2], dtype=uint8) + """ class CompiledDemSampler: """A helper class for efficiently sampler from a detector error model. @@ -4073,13 +4627,13 @@ class CompiledDemSampler: shots: int, *, det_out_file: Union[None, str, pathlib.Path], - det_out_format: str = "01", + det_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_file: Union[None, str, pathlib.Path], - obs_out_format: str = "01", + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', err_out_file: Union[None, str, pathlib.Path] = None, - err_out_format: str = "01", + err_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', replay_err_in_file: Union[None, str, pathlib.Path] = None, - replay_err_in_format: str = "01", + replay_err_in_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples the detector error model and writes the results to disk. @@ -4151,7 +4705,7 @@ class CompiledDetectorSampler: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, seed: object = None, ) -> None: @@ -4333,9 +4887,9 @@ class CompiledDetectorSampler: shots: int, *, filepath: Union[str, pathlib.Path], - format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, - obs_out_format: 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]' = '01', + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', prepend_observables: bool = False, append_observables: bool = False, ) -> None: @@ -4389,7 +4943,7 @@ class CompiledMeasurementSampler: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -4539,8 +5093,8 @@ class CompiledMeasurementSampler: self, shots: int, *, - filepath: str, - format: str = '01', + filepath: Union[str, pathlib.Path], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Samples measurements from the circuit and writes them to a file. @@ -4577,7 +5131,7 @@ class CompiledMeasurementsToDetectionEventsConverter: """ def __init__( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -4639,7 +5193,7 @@ class CompiledMeasurementsToDetectionEventsConverter: *, measurements: np.ndarray, sweep_bits: Optional[np.ndarray] = None, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], append_observables: bool = False, bit_packed: bool = False, ) -> Tuple[np.ndarray, np.ndarray]: @@ -4731,15 +5285,15 @@ class CompiledMeasurementsToDetectionEventsConverter: def convert_file( self, *, - measurements_filepath: str, - measurements_format: str = '01', - sweep_bits_filepath: str = None, - sweep_bits_format: str = '01', - detection_events_filepath: str, - detection_events_format: str = '01', + measurements_filepath: Union[str, pathlib.Path], + measurements_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + sweep_bits_filepath: Optional[Union[str, pathlib.Path]] = None, + sweep_bits_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', + detection_events_filepath: Union[str, pathlib.Path], + detection_events_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', append_observables: bool = False, - obs_out_filepath: str = None, - obs_out_format: str = '01', + obs_out_filepath: Optional[Union[str, pathlib.Path]] = None, + obs_out_format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"] = '01', ) -> None: """Reads measurement data from a file and writes detection events to another file. @@ -4812,7 +5366,7 @@ class DemInstruction: """ def __eq__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -4852,7 +5406,7 @@ class DemInstruction: """ def __ne__( self, - arg0: stim.DemInstruction, + arg0: stim._stim_polyfill.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -4980,14 +5534,14 @@ class DemRepeatBlock: """ def __eq__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ def __init__( self, repeat_count: int, - block: stim.DetectorErrorModel, + block: stim._stim_polyfill.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -5006,7 +5560,7 @@ class DemRepeatBlock: """ def __ne__( self, - arg0: stim.DemRepeatBlock, + arg0: stim._stim_polyfill.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -5017,7 +5571,7 @@ class DemRepeatBlock: """ def body_copy( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -5066,7 +5620,7 @@ class DemTarget: """ def __eq__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -5092,7 +5646,7 @@ class DemTarget: """ def __ne__( self, - arg0: stim.DemTarget, + arg0: stim._stim_polyfill.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -5160,7 +5714,7 @@ class DemTarget: @staticmethod def logical_observable_id( index: int, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -5183,7 +5737,7 @@ class DemTarget: @staticmethod def relative_detector_id( index: int, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -5205,7 +5759,7 @@ class DemTarget: """ @staticmethod def separator( - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -5260,7 +5814,7 @@ class DemTargetWithCoords: """ def __init__( self, - dem_target: stim.DemTarget, + dem_target: stim._stim_polyfill.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -5300,7 +5854,7 @@ class DemTargetWithCoords: @property def dem_target( self, - ) -> stim.DemTarget: + ) -> stim._stim_polyfill.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -5378,8 +5932,8 @@ class DetectorErrorModel: """ def __add__( self, - second: stim.DetectorErrorModel, - ) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, + ) -> stim._stim_polyfill.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -5398,7 +5952,7 @@ class DetectorErrorModel: """ def __eq__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -5454,8 +6008,8 @@ class DetectorErrorModel: """ def __iadd__( self, - second: stim.DetectorErrorModel, - ) -> stim.DetectorErrorModel: + second: stim._stim_polyfill.DetectorErrorModel, + ) -> stim._stim_polyfill.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -5476,7 +6030,7 @@ class DetectorErrorModel: def __imul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -5543,7 +6097,7 @@ class DetectorErrorModel: def __mul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -5573,7 +6127,7 @@ class DetectorErrorModel: """ def __ne__( self, - arg0: stim.DetectorErrorModel, + arg0: stim._stim_polyfill.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -5585,7 +6139,7 @@ class DetectorErrorModel: def __rmul__( self, repetitions: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -5757,7 +6311,7 @@ class DetectorErrorModel: self, *, seed: object = None, - ) -> stim.CompiledDemSampler: + ) -> stim._stim_polyfill.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -5817,7 +6371,7 @@ class DetectorErrorModel: """ def copy( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -5834,7 +6388,7 @@ class DetectorErrorModel: """ def diagram( self, - type: str, + type: Literal["matchgraph-svg", "matchgraph-svg-html", "matchgraph-3d", "matchgraph-3d-html"] = 'matchgraph-svg', ) -> Any: """Returns a diagram of the circuit, from a variety of options. @@ -5888,7 +6442,7 @@ class DetectorErrorModel: """ def flattened( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -6069,7 +6623,7 @@ class DetectorErrorModel: def rounded( self, arg0: int, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -6105,7 +6659,7 @@ class DetectorErrorModel: def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -6227,7 +6781,7 @@ class DetectorErrorModel: """ def without_tags( self, - ) -> stim.DetectorErrorModel: + ) -> stim._stim_polyfill.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -6271,8 +6825,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim.DemTargetWithCoords], - circuit_error_locations: List[stim.CircuitErrorLocation], + dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], + circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -6301,7 +6855,7 @@ class ExplainedError: @property def circuit_error_locations( self, - ) -> List[stim.CircuitErrorLocation]: + ) -> List[stim._stim_polyfill.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -6334,7 +6888,7 @@ class ExplainedError: @property def dem_error_terms( self, - ) -> List[stim.DemTargetWithCoords]: + ) -> List[stim._stim_polyfill.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ class FlipSimulator: @@ -7335,7 +7889,7 @@ class FlippedMeasurement: @property def observable( self, - ) -> List[stim.GateTargetWithCoords]: + ) -> List[stim._stim_polyfill.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -7408,7 +7962,7 @@ class Flow: """ def __eq__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -7428,7 +7982,7 @@ class Flow: the string "X_ -> ZZ xor rec[-1]" will result in a flow with input pauli string "X_", output pauli string "ZZ", and measurement indices [-1]. - Arguments: + Args: arg [position-only]: Defaults to None. Must be specified by itself if used. str: Initializes a flow by parsing the given shorthand text. stim.Flow: Initializes a copy of the given flow. @@ -7475,8 +8029,8 @@ class Flow: """ def __mul__( self, - rhs: stim.Flow, - ) -> stim.Flow: + rhs: stim._stim_polyfill.Flow, + ) -> stim._stim_polyfill.Flow: """Computes the product of two flows. Args: @@ -7502,7 +8056,7 @@ class Flow: """ def __ne__( self, - arg0: stim.Flow, + arg0: stim._stim_polyfill.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -7542,7 +8096,7 @@ class Flow: """ def input_copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -7570,7 +8124,7 @@ class Flow: """ def output_copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -7603,7 +8157,7 @@ class GateData: """ def __eq__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -7620,7 +8174,7 @@ class GateData: """ def __ne__( self, - arg0: stim.GateData, + arg0: stim._stim_polyfill.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -7690,7 +8244,7 @@ class GateData: @property def generalized_inverse( self, - ) -> stim.GateData: + ) -> stim._stim_polyfill.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -8262,7 +8816,7 @@ class GateTarget: """ def __eq__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -8291,7 +8845,7 @@ class GateTarget: """ def __ne__( self, - arg0: stim.GateTarget, + arg0: stim._stim_polyfill.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -8614,7 +9168,7 @@ class GateTargetWithCoords: @property def gate_target( self, - ) -> stim.GateTarget: + ) -> stim._stim_polyfill.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -8638,8 +9192,8 @@ class PauliString: """ def __add__( self, - rhs: stim.PauliString, - ) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -8661,7 +9215,7 @@ class PauliString: """ def __eq__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -8710,8 +9264,8 @@ class PauliString: """ def __iadd__( self, - rhs: stim.PauliString, - ) -> stim.PauliString: + rhs: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -8737,7 +9291,7 @@ class PauliString: def __imul__( self, rhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -8780,7 +9334,7 @@ class PauliString: """ def __init__( self, - arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, + arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, Literal["_", "I", "X", "Y", "Z"]]]] = None, /, ) -> None: """Initializes a stim.PauliString from the given argument. @@ -8793,7 +9347,7 @@ class PauliString: pauli string is a series of integers seperated by '*' and prefixed by 'I', 'X', 'Y', or 'Z'. - Arguments: + Args: arg [position-only]: This can be a variety of types, including: None (default): initializes an empty Pauli string. int: initializes an identity Pauli string of the given length. @@ -8850,7 +9404,7 @@ class PauliString: def __itruediv__( self, rhs: complex, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -8885,7 +9439,7 @@ class PauliString: def __mul__( self, rhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -8936,13 +9490,13 @@ class PauliString: """ def __ne__( self, - arg0: stim.PauliString, + arg0: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ def __neg__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the negation of the pauli string. Examples: @@ -8956,7 +9510,7 @@ class PauliString: """ def __pos__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a pauli string with the same contents. Examples: @@ -8976,7 +9530,7 @@ class PauliString: def __rmul__( self, lhs: object, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9064,7 +9618,7 @@ class PauliString: def __truediv__( self, rhs: complex, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -9180,7 +9734,7 @@ class PauliString: """ def commutes( self, - other: stim.PauliString, + other: stim._stim_polyfill.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -9213,7 +9767,7 @@ class PauliString: """ def copy( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -9229,8 +9783,8 @@ class PauliString: """ def extended_product( self, - other: stim.PauliString, - ) -> Tuple[complex, stim.PauliString]: + other: stim._stim_polyfill.PauliString, + ) -> Tuple[complex, stim._stim_polyfill.PauliString]: """[DEPRECATED] Use multiplication (__mul__ or *) instead. """ @staticmethod @@ -9287,7 +9841,7 @@ class PauliString: def from_unitary_matrix( matrix: Iterable[Iterable[Union[int, float, complex]]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', unsigned: bool = False, ) -> stim.PauliString: """Creates a stim.PauliString from the unitary matrix of a Pauli group member. @@ -9343,7 +9897,7 @@ class PauliString: min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', - ) -> stim.PauliStringIterator: + ) -> stim._stim_polyfill.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -9433,7 +9987,7 @@ class PauliString: num_qubits: int, *, allow_imaginary: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -9533,7 +10087,7 @@ class PauliString: """ def to_tableau( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -9577,7 +10131,7 @@ class PauliString: def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the pauli string into a unitary matrix. @@ -9637,7 +10191,7 @@ class PauliStringIterator: """ def __iter__( self, - ) -> stim.PauliStringIterator: + ) -> stim._stim_polyfill.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -9646,7 +10200,7 @@ class PauliStringIterator: """ def __next__( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the next iterated pauli string. """ class Tableau: @@ -9684,8 +10238,8 @@ class Tableau: """ def __add__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -9708,8 +10262,8 @@ class Tableau: """ def __call__( self, - pauli_string: stim.PauliString, - ) -> stim.PauliString: + pauli_string: stim._stim_polyfill.PauliString, + ) -> stim._stim_polyfill.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -9740,14 +10294,14 @@ class Tableau: """ def __eq__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ def __iadd__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -9804,8 +10358,8 @@ class Tableau: """ def __mul__( self, - rhs: stim.Tableau, - ) -> stim.Tableau: + rhs: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -9826,14 +10380,14 @@ class Tableau: """ def __ne__( self, - arg0: stim.Tableau, + arg0: stim._stim_polyfill.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ def __pow__( self, exponent: int, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -9895,7 +10449,7 @@ class Tableau: """ def copy( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -9964,9 +10518,9 @@ class Tableau: @staticmethod def from_conjugated_generators( *, - xs: List[stim.PauliString], - zs: List[stim.PauliString], - ) -> stim.Tableau: + xs: List[stim._stim_polyfill.PauliString], + zs: List[stim._stim_polyfill.PauliString], + ) -> stim._stim_polyfill.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -10002,7 +10556,7 @@ class Tableau: @staticmethod def from_named_gate( name: str, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -10212,7 +10766,7 @@ class Tableau: def from_state_vector( state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> stim.Tableau: """Creates a tableau representing the stabilizer state of the given state vector. @@ -10273,7 +10827,7 @@ class Tableau: def from_unitary_matrix( matrix: Iterable[Iterable[float]], *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> stim.Tableau: """Creates a tableau from the unitary matrix of a Clifford operation. @@ -10329,7 +10883,7 @@ class Tableau: self, *, unsigned: bool = False, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -10396,7 +10950,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -10466,7 +11020,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -10536,7 +11090,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -10608,7 +11162,7 @@ class Tableau: num_qubits: int, *, unsigned: bool = False, - ) -> stim.TableauIterator: + ) -> stim._stim_polyfill.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -10658,7 +11212,7 @@ class Tableau: @staticmethod def random( num_qubits: int, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -10678,8 +11232,8 @@ class Tableau: """ def then( self, - second: stim.Tableau, - ) -> stim.Tableau: + second: stim._stim_polyfill.Tableau, + ) -> stim._stim_polyfill.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -10702,7 +11256,7 @@ class Tableau: """ def to_circuit( self, - method: 'Literal["elimination", "graph_state"]' = 'elimination', + method: Literal["elimination", "graph_state"] = 'elimination', ) -> stim.Circuit: """Synthesizes a circuit that implements the tableau's Clifford operation. @@ -10989,7 +11543,7 @@ class Tableau: """ def to_pauli_string( self, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -11021,7 +11575,7 @@ class Tableau: self, *, canonicalize: bool = False, - ) -> List[stim.PauliString]: + ) -> List[stim._stim_polyfill.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -11069,7 +11623,7 @@ class Tableau: def to_state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns the state vector produced by applying the tableau to the |0..0> state. @@ -11121,7 +11675,7 @@ class Tableau: def to_unitary_matrix( self, *, - endian: str, + endian: Literal["little", "big"], ) -> np.ndarray[np.complex64]: """Converts the tableau into a unitary matrix. @@ -11166,7 +11720,7 @@ class Tableau: def x_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -11241,7 +11795,7 @@ class Tableau: def y_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -11318,7 +11872,7 @@ class Tableau: def z_output( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -11404,7 +11958,7 @@ class TableauIterator: """ def __iter__( self, - ) -> stim.TableauIterator: + ) -> stim._stim_polyfill.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -11413,7 +11967,7 @@ class TableauIterator: """ def __next__( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns the next iterated tableau. """ class TableauSimulator: @@ -11537,7 +12091,7 @@ class TableauSimulator: """ def canonical_stabilizers( self, - ) -> List[stim.PauliString]: + ) -> List[stim._stim_polyfill.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -11683,7 +12237,7 @@ class TableauSimulator: """ def current_inverse_tableau( self, - ) -> stim.Tableau: + ) -> stim._stim_polyfill.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -11873,7 +12427,7 @@ class TableauSimulator: """ def do_circuit( self, - circuit: stim.Circuit, + circuit: stim._stim_polyfill.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -11892,7 +12446,7 @@ class TableauSimulator: """ def do_pauli_string( self, - pauli_string: stim.PauliString, + pauli_string: stim._stim_polyfill.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -11908,7 +12462,7 @@ class TableauSimulator: """ def do_tableau( self, - tableau: stim.Tableau, + tableau: stim._stim_polyfill.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -12181,7 +12735,7 @@ class TableauSimulator: """ def measure_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -12238,7 +12792,7 @@ class TableauSimulator: def peek_bloch( self, target: int, - ) -> stim.PauliString: + ) -> stim._stim_polyfill.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -12283,7 +12837,7 @@ class TableauSimulator: """ def peek_observable_expectation( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, ) -> int: """Determines the expected value of an observable. @@ -12428,7 +12982,7 @@ class TableauSimulator: """ def postselect_observable( self, - observable: stim.PauliString, + observable: stim._stim_polyfill.PauliString, *, desired_value: bool = False, ) -> None: @@ -12687,7 +13241,7 @@ class TableauSimulator: """ def set_inverse_tableau( self, - new_inverse_tableau: stim.Tableau, + new_inverse_tableau: stim._stim_polyfill.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -12843,7 +13397,7 @@ class TableauSimulator: self, state_vector: Iterable[float], *, - endian: str, + endian: Literal["little", "big"], ) -> None: """Sets the simulator's state to a superposition specified by an amplitude vector. @@ -12989,7 +13543,7 @@ class TableauSimulator: def state_vector( self, *, - endian: str = 'little', + endian: Literal["little", "big"] = 'little', ) -> np.ndarray[np.complex64]: """Returns a wavefunction for the simulator's current state. @@ -13484,7 +14038,7 @@ def main( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -13495,18 +14049,18 @@ def read_shot_data_file( def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, - separate_observables: 'Literal[True]', + separate_observables: Literal[True], ) -> Tuple[np.ndarray, np.ndarray]: pass def read_shot_data_file( *, path: Union[str, pathlib.Path], - format: Union[str, 'Literal["01", "b8", "r8", "ptb64", "hits", "dets"]'], + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], bit_packed: bool = False, num_measurements: int = 0, num_detectors: int = 0, @@ -13611,7 +14165,7 @@ def target_combined_paulis( ''') """ def target_combiner( -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -13653,7 +14207,7 @@ def target_inv( """ def target_logical_observable_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -13714,7 +14268,7 @@ def target_pauli( """ def target_rec( lookback_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -13741,7 +14295,7 @@ def target_rec( """ def target_relative_detector_id( index: int, -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -13762,7 +14316,7 @@ def target_relative_detector_id( ''') """ def target_separator( -) -> stim.DemTarget: +) -> stim._stim_polyfill.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -13780,7 +14334,7 @@ def target_separator( """ def target_sweep_bit( sweep_bit_index: int, -) -> stim.GateTarget: +) -> stim._stim_polyfill.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: @@ -13877,7 +14431,7 @@ def write_shot_data_file( *, data: np.ndarray, path: Union[str, pathlib.Path], - format: str, + format: Literal["01", "b8", "r8", "ptb64", "hits", "dets"], num_measurements: int = 0, num_detectors: int = 0, num_observables: int = 0, From 092c8d99095495389b0c775131fe50a82da55e3c Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Wed, 21 Jan 2026 01:23:19 +0000 Subject: [PATCH 09/10] build and install wheel then regen_docs --- doc/python_api_reference_vDev.md | 328 ++++++++++++++--------------- doc/stim.pyi | 332 +++++++++++++++--------------- glue/python/src/stim/__init__.pyi | 332 +++++++++++++++--------------- 3 files changed, 496 insertions(+), 496 deletions(-) diff --git a/doc/python_api_reference_vDev.md b/doc/python_api_reference_vDev.md index 6ba04c52f..01ce7fe4b 100644 --- a/doc/python_api_reference_vDev.md +++ b/doc/python_api_reference_vDev.md @@ -522,8 +522,8 @@ class Circuit: # (in class stim.Circuit) def __add__( self, - second: stim._stim_polyfill.Circuit, -) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, +) -> stim.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -551,7 +551,7 @@ def __add__( # (in class stim.Circuit) def __eq__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -625,8 +625,8 @@ def __getitem__( # (in class stim.Circuit) def __iadd__( self, - second: stim._stim_polyfill.Circuit, -) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, +) -> stim.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -656,7 +656,7 @@ def __iadd__( def __imul__( self, repetitions: int, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -750,7 +750,7 @@ def __len__( def __mul__( self, repetitions: int, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -787,7 +787,7 @@ def __mul__( # (in class stim.Circuit) def __ne__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -813,7 +813,7 @@ def __repr__( def __rmul__( self, repetitions: int, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -1071,7 +1071,7 @@ def compile_detector_sampler( self, *, seed: object = None, -) -> stim._stim_polyfill.CompiledDetectorSampler: +) -> stim.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -1123,7 +1123,7 @@ def compile_m2d_converter( self, *, skip_reference_sample: bool = False, -) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: +) -> stim.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -1251,7 +1251,7 @@ def compile_sampler( # (in class stim.Circuit) def copy( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -1377,7 +1377,7 @@ def count_determined_measurements( # (in class stim.Circuit) def decomposed( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -1591,7 +1591,7 @@ def detector_error_model( approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1825,7 +1825,7 @@ def explain_detector_error_model_errors( *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, -) -> List[stim._stim_polyfill.ExplainedError]: +) -> List[stim.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1885,7 +1885,7 @@ def explain_detector_error_model_errors( # (in class stim.Circuit) def flattened( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -2043,7 +2043,7 @@ def generated( before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -2455,7 +2455,7 @@ def insert( # (in class stim.Circuit) def inverse( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2985,7 +2985,7 @@ def search_for_undetectable_logical_errors( dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, -) -> List[stim._stim_polyfill.ExplainedError]: +) -> List[stim.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -3157,7 +3157,7 @@ def shortest_graphlike_error( *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, -) -> List[stim._stim_polyfill.ExplainedError]: +) -> List[stim.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -3791,7 +3791,7 @@ def to_tableau( # (in class stim.Circuit) def with_inlined_feedback( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3852,7 +3852,7 @@ def with_inlined_feedback( # (in class stim.Circuit) def without_noise( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3886,7 +3886,7 @@ def without_noise( # (in class stim.Circuit) def without_tags( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3945,10 +3945,10 @@ def __init__( self, *, tick_offset: int, - flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], + flipped_pauli_product: List[stim.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, - stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], + instruction_targets: stim.CircuitTargetsInsideInstruction, + stack_frames: List[stim.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -4035,7 +4035,7 @@ def flipped_measurement( @property def flipped_pauli_product( self, -) -> List[stim._stim_polyfill.GateTargetWithCoords]: +) -> List[stim.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -4061,7 +4061,7 @@ def flipped_pauli_product( @property def instruction_targets( self, -) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: +) -> stim.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -4119,7 +4119,7 @@ def noise_tag( @property def stack_frames( self, -) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: +) -> List[stim.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -4359,7 +4359,7 @@ class CircuitInstruction: # (in class stim.CircuitInstruction) def __eq__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -4417,7 +4417,7 @@ def __init__( # (in class stim.CircuitInstruction) def __ne__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -4591,7 +4591,7 @@ def target_groups( # (in class stim.CircuitInstruction) def targets_copy( self, -) -> List[stim._stim_polyfill.GateTarget]: +) -> List[stim.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -4642,7 +4642,7 @@ class CircuitRepeatBlock: # (in class stim.CircuitRepeatBlock) def __eq__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ @@ -4656,7 +4656,7 @@ def __eq__( def __init__( self, repeat_count: int, - body: stim._stim_polyfill.Circuit, + body: stim.Circuit, *, tag: str = '', ) -> None: @@ -4687,7 +4687,7 @@ def __init__( # (in class stim.CircuitRepeatBlock) def __ne__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -4712,7 +4712,7 @@ def __repr__( # (in class stim.CircuitRepeatBlock) def body_copy( self, -) -> stim._stim_polyfill.Circuit: +) -> stim.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -4868,7 +4868,7 @@ def __init__( args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], + targets_in_range: List[stim.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -5029,7 +5029,7 @@ def target_range_start( @property def targets_in_range( self, -) -> List[stim._stim_polyfill.GateTargetWithCoords]: +) -> List[stim.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -5074,8 +5074,8 @@ class CliffordString: # (in class stim.CliffordString) def __add__( self, - rhs: stim._stim_polyfill.CliffordString, -) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, +) -> stim.CliffordString: """Concatenates two CliffordStrings. Args: @@ -5098,7 +5098,7 @@ def __add__( # (in class stim.CliffordString) def __eq__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have identical contents. """ @@ -5160,8 +5160,8 @@ def __getitem__( # (in class stim.CliffordString) def __iadd__( self, - rhs: stim._stim_polyfill.CliffordString, -) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, +) -> stim.CliffordString: """Mutates the CliffordString by concatenating onto it. Args: @@ -5365,7 +5365,7 @@ def __mul__( # (in class stim.CliffordString) def __ne__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have non-identical contents. """ @@ -5379,7 +5379,7 @@ def __ne__( def __pow__( self, power: int, -) -> stim._stim_polyfill.CliffordString: +) -> stim.CliffordString: """Returns the CliffordString raised to a power. Args: @@ -5434,7 +5434,7 @@ def __repr__( def __rmul__( self, lhs: int, -) -> stim._stim_polyfill.CliffordString: +) -> stim.CliffordString: """CliffordString left-multiplication. Args: @@ -5540,7 +5540,7 @@ def __str__( # (in class stim.CliffordString) @staticmethod def all_cliffords_string( -) -> stim._stim_polyfill.CliffordString: +) -> stim.CliffordString: """Returns a stim.CliffordString containing each single qubit Clifford once. Useful for things like testing that a method works on every single Clifford. @@ -5569,7 +5569,7 @@ def all_cliffords_string( # (in class stim.CliffordString) def copy( self, -) -> stim._stim_polyfill.CliffordString: +) -> stim.CliffordString: """Returns a copy of the CliffordString. Returns: @@ -5596,7 +5596,7 @@ def copy( @staticmethod def random( num_qubits: int, -) -> stim._stim_polyfill.CliffordString: +) -> stim.CliffordString: """Samples a uniformly random CliffordString. Args: @@ -6052,7 +6052,7 @@ class CompiledDetectorSampler: # (in class stim.CompiledDetectorSampler) def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, seed: object = None, ) -> None: @@ -6297,7 +6297,7 @@ class CompiledMeasurementSampler: # (in class stim.CompiledMeasurementSampler) def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -6492,7 +6492,7 @@ class CompiledMeasurementsToDetectionEventsConverter: # (in class stim.CompiledMeasurementsToDetectionEventsConverter) def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -6762,7 +6762,7 @@ class DemInstruction: # (in class stim.DemInstruction) def __eq__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -6816,7 +6816,7 @@ def __init__( # (in class stim.DemInstruction) def __ne__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -7007,7 +7007,7 @@ class DemRepeatBlock: # (in class stim.DemRepeatBlock) def __eq__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ @@ -7021,7 +7021,7 @@ def __eq__( def __init__( self, repeat_count: int, - block: stim._stim_polyfill.DetectorErrorModel, + block: stim.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -7047,7 +7047,7 @@ def __init__( # (in class stim.DemRepeatBlock) def __ne__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -7072,7 +7072,7 @@ def __repr__( # (in class stim.DemRepeatBlock) def body_copy( self, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -7149,7 +7149,7 @@ class DemTarget: # (in class stim.DemTarget) def __eq__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -7189,7 +7189,7 @@ def __init__( # (in class stim.DemTarget) def __ne__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -7299,7 +7299,7 @@ def is_separator( @staticmethod def logical_observable_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -7329,7 +7329,7 @@ def logical_observable_id( @staticmethod def relative_detector_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -7358,7 +7358,7 @@ def relative_detector_id( # (in class stim.DemTarget) @staticmethod def separator( -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -7434,7 +7434,7 @@ class DemTargetWithCoords: # (in class stim.DemTargetWithCoords) def __init__( self, - dem_target: stim._stim_polyfill.DemTarget, + dem_target: stim.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -7488,7 +7488,7 @@ def coords( @property def dem_target( self, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -7580,8 +7580,8 @@ class DetectorErrorModel: # (in class stim.DetectorErrorModel) def __add__( self, - second: stim._stim_polyfill.DetectorErrorModel, -) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, +) -> stim.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -7607,7 +7607,7 @@ def __add__( # (in class stim.DetectorErrorModel) def __eq__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -7677,8 +7677,8 @@ def __getitem__( # (in class stim.DetectorErrorModel) def __iadd__( self, - second: stim._stim_polyfill.DetectorErrorModel, -) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, +) -> stim.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -7706,7 +7706,7 @@ def __iadd__( def __imul__( self, repetitions: int, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -7794,7 +7794,7 @@ def __len__( def __mul__( self, repetitions: int, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -7831,7 +7831,7 @@ def __mul__( # (in class stim.DetectorErrorModel) def __ne__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -7857,7 +7857,7 @@ def __repr__( def __rmul__( self, repetitions: int, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -8064,7 +8064,7 @@ def compile_sampler( self, *, seed: object = None, -) -> stim._stim_polyfill.CompiledDemSampler: +) -> stim.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -8131,7 +8131,7 @@ def compile_sampler( # (in class stim.DetectorErrorModel) def copy( self, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -8216,7 +8216,7 @@ def diagram( # (in class stim.DetectorErrorModel) def flattened( self, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -8439,7 +8439,7 @@ def num_observables( def rounded( self, arg0: int, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -8482,7 +8482,7 @@ def rounded( def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -8618,7 +8618,7 @@ def to_file( # (in class stim.DetectorErrorModel) def without_tags( self, -) -> stim._stim_polyfill.DetectorErrorModel: +) -> stim.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -8676,8 +8676,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], - circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], + dem_error_terms: List[stim.DemTargetWithCoords], + circuit_error_locations: List[stim.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -8713,7 +8713,7 @@ def __init__( @property def circuit_error_locations( self, -) -> List[stim._stim_polyfill.CircuitErrorLocation]: +) -> List[stim.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -8753,7 +8753,7 @@ def circuit_error_locations( @property def dem_error_terms( self, -) -> List[stim._stim_polyfill.DemTargetWithCoords]: +) -> List[stim.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ ``` @@ -9908,7 +9908,7 @@ def __init__( @property def observable( self, -) -> List[stim._stim_polyfill.GateTargetWithCoords]: +) -> List[stim.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -10002,7 +10002,7 @@ class Flow: # (in class stim.Flow) def __eq__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -10083,8 +10083,8 @@ def __init__( # (in class stim.Flow) def __mul__( self, - rhs: stim._stim_polyfill.Flow, -) -> stim._stim_polyfill.Flow: + rhs: stim.Flow, +) -> stim.Flow: """Computes the product of two flows. Args: @@ -10117,7 +10117,7 @@ def __mul__( # (in class stim.Flow) def __ne__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -10185,7 +10185,7 @@ def included_observables_copy( # (in class stim.Flow) def input_copy( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -10227,7 +10227,7 @@ def measurements_copy( # (in class stim.Flow) def output_copy( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -10274,7 +10274,7 @@ class GateData: # (in class stim.GateData) def __eq__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -10305,7 +10305,7 @@ def __init__( # (in class stim.GateData) def __ne__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -10410,7 +10410,7 @@ def flows( @property def generalized_inverse( self, -) -> stim._stim_polyfill.GateData: +) -> stim.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -11101,7 +11101,7 @@ class GateTarget: # (in class stim.GateTarget) def __eq__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -11144,7 +11144,7 @@ def __init__( # (in class stim.GateTarget) def __ne__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -11579,7 +11579,7 @@ def coords( @property def gate_target( self, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -11617,8 +11617,8 @@ class PauliString: # (in class stim.PauliString) def __add__( self, - rhs: stim._stim_polyfill.PauliString, -) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, +) -> stim.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -11647,7 +11647,7 @@ def __add__( # (in class stim.PauliString) def __eq__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -11710,8 +11710,8 @@ def __getitem__( # (in class stim.PauliString) def __iadd__( self, - rhs: stim._stim_polyfill.PauliString, -) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, +) -> stim.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -11744,7 +11744,7 @@ def __iadd__( def __imul__( self, rhs: object, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -11871,7 +11871,7 @@ def __init__( def __itruediv__( self, rhs: complex, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -11920,7 +11920,7 @@ def __len__( def __mul__( self, rhs: object, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -11978,7 +11978,7 @@ def __mul__( # (in class stim.PauliString) def __ne__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ @@ -11991,7 +11991,7 @@ def __ne__( # (in class stim.PauliString) def __neg__( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the negation of the pauli string. Examples: @@ -12012,7 +12012,7 @@ def __neg__( # (in class stim.PauliString) def __pos__( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns a pauli string with the same contents. Examples: @@ -12046,7 +12046,7 @@ def __repr__( def __rmul__( self, lhs: object, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -12155,7 +12155,7 @@ def __str__( def __truediv__( self, rhs: complex, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -12292,7 +12292,7 @@ def before( # (in class stim.PauliString) def commutes( self, - other: stim._stim_polyfill.PauliString, + other: stim.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -12332,7 +12332,7 @@ def commutes( # (in class stim.PauliString) def copy( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -12477,7 +12477,7 @@ def iter_all( min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', -) -> stim._stim_polyfill.PauliStringIterator: +) -> stim.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -12581,7 +12581,7 @@ def random( num_qubits: int, *, allow_imaginary: bool = False, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -12702,7 +12702,7 @@ def to_numpy( # (in class stim.PauliString) def to_tableau( self, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -12834,7 +12834,7 @@ class PauliStringIterator: # (in class stim.PauliStringIterator) def __iter__( self, -) -> stim._stim_polyfill.PauliStringIterator: +) -> stim.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -12850,7 +12850,7 @@ def __iter__( # (in class stim.PauliStringIterator) def __next__( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the next iterated pauli string. """ ``` @@ -12902,8 +12902,8 @@ class Tableau: # (in class stim.Tableau) def __add__( self, - rhs: stim._stim_polyfill.Tableau, -) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, +) -> stim.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -12933,8 +12933,8 @@ def __add__( # (in class stim.Tableau) def __call__( self, - pauli_string: stim._stim_polyfill.PauliString, -) -> stim._stim_polyfill.PauliString: + pauli_string: stim.PauliString, +) -> stim.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -12972,7 +12972,7 @@ def __call__( # (in class stim.Tableau) def __eq__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ @@ -12985,8 +12985,8 @@ def __eq__( # (in class stim.Tableau) def __iadd__( self, - rhs: stim._stim_polyfill.Tableau, -) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, +) -> stim.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -13064,8 +13064,8 @@ def __len__( # (in class stim.Tableau) def __mul__( self, - rhs: stim._stim_polyfill.Tableau, -) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, +) -> stim.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -13093,7 +13093,7 @@ def __mul__( # (in class stim.Tableau) def __ne__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ @@ -13107,7 +13107,7 @@ def __ne__( def __pow__( self, exponent: int, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -13197,7 +13197,7 @@ def append( # (in class stim.Tableau) def copy( self, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -13280,9 +13280,9 @@ def from_circuit( @staticmethod def from_conjugated_generators( *, - xs: List[stim._stim_polyfill.PauliString], - zs: List[stim._stim_polyfill.PauliString], -) -> stim._stim_polyfill.Tableau: + xs: List[stim.PauliString], + zs: List[stim.PauliString], +) -> stim.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -13325,7 +13325,7 @@ def from_conjugated_generators( @staticmethod def from_named_gate( name: str, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -13687,7 +13687,7 @@ def inverse( self, *, unsigned: bool = False, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -13761,7 +13761,7 @@ def inverse_x_output( input_index: int, *, unsigned: bool = False, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -13845,7 +13845,7 @@ def inverse_y_output( input_index: int, *, unsigned: bool = False, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -13929,7 +13929,7 @@ def inverse_z_output( input_index: int, *, unsigned: bool = False, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -14015,7 +14015,7 @@ def iter_all( num_qubits: int, *, unsigned: bool = False, -) -> stim._stim_polyfill.TableauIterator: +) -> stim.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -14079,7 +14079,7 @@ def prepend( @staticmethod def random( num_qubits: int, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -14106,8 +14106,8 @@ def random( # (in class stim.Tableau) def then( self, - second: stim._stim_polyfill.Tableau, -) -> stim._stim_polyfill.Tableau: + second: stim.Tableau, +) -> stim.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -14438,7 +14438,7 @@ def to_numpy( # (in class stim.Tableau) def to_pauli_string( self, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -14477,7 +14477,7 @@ def to_stabilizers( self, *, canonicalize: bool = False, -) -> List[stim._stim_polyfill.PauliString]: +) -> List[stim.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -14643,7 +14643,7 @@ def to_unitary_matrix( def x_output( self, target: int, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -14739,7 +14739,7 @@ def x_sign( def y_output( self, target: int, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -14837,7 +14837,7 @@ def y_sign( def z_output( self, target: int, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -14951,7 +14951,7 @@ class TableauIterator: # (in class stim.TableauIterator) def __iter__( self, -) -> stim._stim_polyfill.TableauIterator: +) -> stim.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -14967,7 +14967,7 @@ def __iter__( # (in class stim.TableauIterator) def __next__( self, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Returns the next iterated tableau. """ ``` @@ -15126,7 +15126,7 @@ def c_zyx( # (in class stim.TableauSimulator) def canonical_stabilizers( self, -) -> List[stim._stim_polyfill.PauliString]: +) -> List[stim.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -15293,7 +15293,7 @@ def copy( # (in class stim.TableauSimulator) def current_inverse_tableau( self, -) -> stim._stim_polyfill.Tableau: +) -> stim.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -15539,7 +15539,7 @@ def do( # (in class stim.TableauSimulator) def do_circuit( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -15565,7 +15565,7 @@ def do_circuit( # (in class stim.TableauSimulator) def do_pauli_string( self, - pauli_string: stim._stim_polyfill.PauliString, + pauli_string: stim.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -15588,7 +15588,7 @@ def do_pauli_string( # (in class stim.TableauSimulator) def do_tableau( self, - tableau: stim._stim_polyfill.Tableau, + tableau: stim.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -15931,7 +15931,7 @@ def measure_many( # (in class stim.TableauSimulator) def measure_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -16002,7 +16002,7 @@ def num_qubits( def peek_bloch( self, target: int, -) -> stim._stim_polyfill.PauliString: +) -> stim.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -16054,7 +16054,7 @@ def peek_bloch( # (in class stim.TableauSimulator) def peek_observable_expectation( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, ) -> int: """Determines the expected value of an observable. @@ -16227,7 +16227,7 @@ def peek_z( # (in class stim.TableauSimulator) def postselect_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, desired_value: bool = False, ) -> None: @@ -16556,7 +16556,7 @@ def s_dag( # (in class stim.TableauSimulator) def set_inverse_tableau( self, - new_inverse_tableau: stim._stim_polyfill.Tableau, + new_inverse_tableau: stim.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -17683,7 +17683,7 @@ def target_combined_paulis( # (at top-level in the stim module) def target_combiner( -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -17739,7 +17739,7 @@ def target_inv( # (at top-level in the stim module) def target_logical_observable_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -17814,7 +17814,7 @@ def target_pauli( # (at top-level in the stim module) def target_rec( lookback_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -17848,7 +17848,7 @@ def target_rec( # (at top-level in the stim module) def target_relative_detector_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -17876,7 +17876,7 @@ def target_relative_detector_id( # (at top-level in the stim module) def target_separator( -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -17901,7 +17901,7 @@ def target_separator( # (at top-level in the stim module) def target_sweep_bit( sweep_bit_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: diff --git a/doc/stim.pyi b/doc/stim.pyi index 8ae5519df..d71851394 100644 --- a/doc/stim.pyi +++ b/doc/stim.pyi @@ -43,8 +43,8 @@ class Circuit: """ def __add__( self, - second: stim._stim_polyfill.Circuit, - ) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, + ) -> stim.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -65,7 +65,7 @@ class Circuit: """ def __eq__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -125,8 +125,8 @@ class Circuit: """ def __iadd__( self, - second: stim._stim_polyfill.Circuit, - ) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, + ) -> stim.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -149,7 +149,7 @@ class Circuit: def __imul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -222,7 +222,7 @@ class Circuit: def __mul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -252,7 +252,7 @@ class Circuit: """ def __ne__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -264,7 +264,7 @@ class Circuit: def __rmul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -490,7 +490,7 @@ class Circuit: self, *, seed: object = None, - ) -> stim._stim_polyfill.CompiledDetectorSampler: + ) -> stim.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -535,7 +535,7 @@ class Circuit: self, *, skip_reference_sample: bool = False, - ) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: + ) -> stim.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -649,7 +649,7 @@ class Circuit: """ def copy( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -761,7 +761,7 @@ class Circuit: """ def decomposed( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -961,7 +961,7 @@ class Circuit: approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1181,7 +1181,7 @@ class Circuit: *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1234,7 +1234,7 @@ class Circuit: """ def flattened( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -1396,7 +1396,7 @@ class Circuit: before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -1766,7 +1766,7 @@ class Circuit: """ def inverse( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2212,7 +2212,7 @@ class Circuit: dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -2370,7 +2370,7 @@ class Circuit: *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -2948,7 +2948,7 @@ class Circuit: """ def with_inlined_feedback( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3002,7 +3002,7 @@ class Circuit: """ def without_noise( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3029,7 +3029,7 @@ class Circuit: """ def without_tags( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3074,10 +3074,10 @@ class CircuitErrorLocation: self, *, tick_offset: int, - flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], + flipped_pauli_product: List[stim.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, - stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], + instruction_targets: stim.CircuitTargetsInsideInstruction, + stack_frames: List[stim.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -3150,7 +3150,7 @@ class CircuitErrorLocation: @property def flipped_pauli_product( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -3169,7 +3169,7 @@ class CircuitErrorLocation: @property def instruction_targets( self, - ) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: + ) -> stim.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -3213,7 +3213,7 @@ class CircuitErrorLocation: @property def stack_frames( self, - ) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: + ) -> List[stim.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -3397,7 +3397,7 @@ class CircuitInstruction: """ def __eq__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -3441,7 +3441,7 @@ class CircuitInstruction: """ def __ne__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -3559,7 +3559,7 @@ class CircuitInstruction: """ def targets_copy( self, - ) -> List[stim._stim_polyfill.GateTarget]: + ) -> List[stim.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -3596,14 +3596,14 @@ class CircuitRepeatBlock: """ def __eq__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ def __init__( self, repeat_count: int, - body: stim._stim_polyfill.Circuit, + body: stim.Circuit, *, tag: str = '', ) -> None: @@ -3627,7 +3627,7 @@ class CircuitRepeatBlock: """ def __ne__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -3638,7 +3638,7 @@ class CircuitRepeatBlock: """ def body_copy( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -3752,7 +3752,7 @@ class CircuitTargetsInsideInstruction: args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], + targets_in_range: List[stim.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -3871,7 +3871,7 @@ class CircuitTargetsInsideInstruction: @property def targets_in_range( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -3902,8 +3902,8 @@ class CliffordString: """ def __add__( self, - rhs: stim._stim_polyfill.CliffordString, - ) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, + ) -> stim.CliffordString: """Concatenates two CliffordStrings. Args: @@ -3919,7 +3919,7 @@ class CliffordString: """ def __eq__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have identical contents. """ @@ -3967,8 +3967,8 @@ class CliffordString: """ def __iadd__( self, - rhs: stim._stim_polyfill.CliffordString, - ) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, + ) -> stim.CliffordString: """Mutates the CliffordString by concatenating onto it. Args: @@ -4130,14 +4130,14 @@ class CliffordString: """ def __ne__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have non-identical contents. """ def __pow__( self, power: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns the CliffordString raised to a power. Args: @@ -4178,7 +4178,7 @@ class CliffordString: def __rmul__( self, lhs: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """CliffordString left-multiplication. Args: @@ -4263,7 +4263,7 @@ class CliffordString: """ @staticmethod def all_cliffords_string( - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns a stim.CliffordString containing each single qubit Clifford once. Useful for things like testing that a method works on every single Clifford. @@ -4285,7 +4285,7 @@ class CliffordString: """ def copy( self, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns a copy of the CliffordString. Returns: @@ -4305,7 +4305,7 @@ class CliffordString: @staticmethod def random( num_qubits: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Samples a uniformly random CliffordString. Args: @@ -4705,7 +4705,7 @@ class CompiledDetectorSampler: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, seed: object = None, ) -> None: @@ -4943,7 +4943,7 @@ class CompiledMeasurementSampler: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -5131,7 +5131,7 @@ class CompiledMeasurementsToDetectionEventsConverter: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -5366,7 +5366,7 @@ class DemInstruction: """ def __eq__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -5406,7 +5406,7 @@ class DemInstruction: """ def __ne__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -5534,14 +5534,14 @@ class DemRepeatBlock: """ def __eq__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ def __init__( self, repeat_count: int, - block: stim._stim_polyfill.DetectorErrorModel, + block: stim.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -5560,7 +5560,7 @@ class DemRepeatBlock: """ def __ne__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -5571,7 +5571,7 @@ class DemRepeatBlock: """ def body_copy( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -5620,7 +5620,7 @@ class DemTarget: """ def __eq__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -5646,7 +5646,7 @@ class DemTarget: """ def __ne__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -5714,7 +5714,7 @@ class DemTarget: @staticmethod def logical_observable_id( index: int, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -5737,7 +5737,7 @@ class DemTarget: @staticmethod def relative_detector_id( index: int, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -5759,7 +5759,7 @@ class DemTarget: """ @staticmethod def separator( - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -5814,7 +5814,7 @@ class DemTargetWithCoords: """ def __init__( self, - dem_target: stim._stim_polyfill.DemTarget, + dem_target: stim.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -5854,7 +5854,7 @@ class DemTargetWithCoords: @property def dem_target( self, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -5932,8 +5932,8 @@ class DetectorErrorModel: """ def __add__( self, - second: stim._stim_polyfill.DetectorErrorModel, - ) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, + ) -> stim.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -5952,7 +5952,7 @@ class DetectorErrorModel: """ def __eq__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -6008,8 +6008,8 @@ class DetectorErrorModel: """ def __iadd__( self, - second: stim._stim_polyfill.DetectorErrorModel, - ) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, + ) -> stim.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -6030,7 +6030,7 @@ class DetectorErrorModel: def __imul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -6097,7 +6097,7 @@ class DetectorErrorModel: def __mul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -6127,7 +6127,7 @@ class DetectorErrorModel: """ def __ne__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -6139,7 +6139,7 @@ class DetectorErrorModel: def __rmul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -6311,7 +6311,7 @@ class DetectorErrorModel: self, *, seed: object = None, - ) -> stim._stim_polyfill.CompiledDemSampler: + ) -> stim.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -6371,7 +6371,7 @@ class DetectorErrorModel: """ def copy( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -6442,7 +6442,7 @@ class DetectorErrorModel: """ def flattened( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -6623,7 +6623,7 @@ class DetectorErrorModel: def rounded( self, arg0: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -6659,7 +6659,7 @@ class DetectorErrorModel: def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -6781,7 +6781,7 @@ class DetectorErrorModel: """ def without_tags( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -6825,8 +6825,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], - circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], + dem_error_terms: List[stim.DemTargetWithCoords], + circuit_error_locations: List[stim.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -6855,7 +6855,7 @@ class ExplainedError: @property def circuit_error_locations( self, - ) -> List[stim._stim_polyfill.CircuitErrorLocation]: + ) -> List[stim.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -6888,7 +6888,7 @@ class ExplainedError: @property def dem_error_terms( self, - ) -> List[stim._stim_polyfill.DemTargetWithCoords]: + ) -> List[stim.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ class FlipSimulator: @@ -7889,7 +7889,7 @@ class FlippedMeasurement: @property def observable( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -7962,7 +7962,7 @@ class Flow: """ def __eq__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -8029,8 +8029,8 @@ class Flow: """ def __mul__( self, - rhs: stim._stim_polyfill.Flow, - ) -> stim._stim_polyfill.Flow: + rhs: stim.Flow, + ) -> stim.Flow: """Computes the product of two flows. Args: @@ -8056,7 +8056,7 @@ class Flow: """ def __ne__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -8096,7 +8096,7 @@ class Flow: """ def input_copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -8124,7 +8124,7 @@ class Flow: """ def output_copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -8157,7 +8157,7 @@ class GateData: """ def __eq__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -8174,7 +8174,7 @@ class GateData: """ def __ne__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -8244,7 +8244,7 @@ class GateData: @property def generalized_inverse( self, - ) -> stim._stim_polyfill.GateData: + ) -> stim.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -8816,7 +8816,7 @@ class GateTarget: """ def __eq__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -8845,7 +8845,7 @@ class GateTarget: """ def __ne__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -9168,7 +9168,7 @@ class GateTargetWithCoords: @property def gate_target( self, - ) -> stim._stim_polyfill.GateTarget: + ) -> stim.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -9192,8 +9192,8 @@ class PauliString: """ def __add__( self, - rhs: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, + ) -> stim.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -9215,7 +9215,7 @@ class PauliString: """ def __eq__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -9264,8 +9264,8 @@ class PauliString: """ def __iadd__( self, - rhs: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, + ) -> stim.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -9291,7 +9291,7 @@ class PauliString: def __imul__( self, rhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9404,7 +9404,7 @@ class PauliString: def __itruediv__( self, rhs: complex, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -9439,7 +9439,7 @@ class PauliString: def __mul__( self, rhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9490,13 +9490,13 @@ class PauliString: """ def __ne__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ def __neg__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the negation of the pauli string. Examples: @@ -9510,7 +9510,7 @@ class PauliString: """ def __pos__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a pauli string with the same contents. Examples: @@ -9530,7 +9530,7 @@ class PauliString: def __rmul__( self, lhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9618,7 +9618,7 @@ class PauliString: def __truediv__( self, rhs: complex, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -9734,7 +9734,7 @@ class PauliString: """ def commutes( self, - other: stim._stim_polyfill.PauliString, + other: stim.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -9767,7 +9767,7 @@ class PauliString: """ def copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -9783,8 +9783,8 @@ class PauliString: """ def extended_product( self, - other: stim._stim_polyfill.PauliString, - ) -> Tuple[complex, stim._stim_polyfill.PauliString]: + other: stim.PauliString, + ) -> Tuple[complex, stim.PauliString]: """[DEPRECATED] Use multiplication (__mul__ or *) instead. """ @staticmethod @@ -9897,7 +9897,7 @@ class PauliString: min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', - ) -> stim._stim_polyfill.PauliStringIterator: + ) -> stim.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -9987,7 +9987,7 @@ class PauliString: num_qubits: int, *, allow_imaginary: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -10087,7 +10087,7 @@ class PauliString: """ def to_tableau( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -10191,7 +10191,7 @@ class PauliStringIterator: """ def __iter__( self, - ) -> stim._stim_polyfill.PauliStringIterator: + ) -> stim.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -10200,7 +10200,7 @@ class PauliStringIterator: """ def __next__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the next iterated pauli string. """ class Tableau: @@ -10238,8 +10238,8 @@ class Tableau: """ def __add__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -10262,8 +10262,8 @@ class Tableau: """ def __call__( self, - pauli_string: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + pauli_string: stim.PauliString, + ) -> stim.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -10294,14 +10294,14 @@ class Tableau: """ def __eq__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ def __iadd__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -10358,8 +10358,8 @@ class Tableau: """ def __mul__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -10380,14 +10380,14 @@ class Tableau: """ def __ne__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ def __pow__( self, exponent: int, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -10449,7 +10449,7 @@ class Tableau: """ def copy( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -10518,9 +10518,9 @@ class Tableau: @staticmethod def from_conjugated_generators( *, - xs: List[stim._stim_polyfill.PauliString], - zs: List[stim._stim_polyfill.PauliString], - ) -> stim._stim_polyfill.Tableau: + xs: List[stim.PauliString], + zs: List[stim.PauliString], + ) -> stim.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -10556,7 +10556,7 @@ class Tableau: @staticmethod def from_named_gate( name: str, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -10883,7 +10883,7 @@ class Tableau: self, *, unsigned: bool = False, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -10950,7 +10950,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -11020,7 +11020,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -11090,7 +11090,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -11162,7 +11162,7 @@ class Tableau: num_qubits: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.TableauIterator: + ) -> stim.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -11212,7 +11212,7 @@ class Tableau: @staticmethod def random( num_qubits: int, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -11232,8 +11232,8 @@ class Tableau: """ def then( self, - second: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + second: stim.Tableau, + ) -> stim.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -11543,7 +11543,7 @@ class Tableau: """ def to_pauli_string( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -11575,7 +11575,7 @@ class Tableau: self, *, canonicalize: bool = False, - ) -> List[stim._stim_polyfill.PauliString]: + ) -> List[stim.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -11720,7 +11720,7 @@ class Tableau: def x_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -11795,7 +11795,7 @@ class Tableau: def y_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -11872,7 +11872,7 @@ class Tableau: def z_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -11958,7 +11958,7 @@ class TableauIterator: """ def __iter__( self, - ) -> stim._stim_polyfill.TableauIterator: + ) -> stim.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -11967,7 +11967,7 @@ class TableauIterator: """ def __next__( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns the next iterated tableau. """ class TableauSimulator: @@ -12091,7 +12091,7 @@ class TableauSimulator: """ def canonical_stabilizers( self, - ) -> List[stim._stim_polyfill.PauliString]: + ) -> List[stim.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -12237,7 +12237,7 @@ class TableauSimulator: """ def current_inverse_tableau( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -12427,7 +12427,7 @@ class TableauSimulator: """ def do_circuit( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -12446,7 +12446,7 @@ class TableauSimulator: """ def do_pauli_string( self, - pauli_string: stim._stim_polyfill.PauliString, + pauli_string: stim.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -12462,7 +12462,7 @@ class TableauSimulator: """ def do_tableau( self, - tableau: stim._stim_polyfill.Tableau, + tableau: stim.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -12735,7 +12735,7 @@ class TableauSimulator: """ def measure_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -12792,7 +12792,7 @@ class TableauSimulator: def peek_bloch( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -12837,7 +12837,7 @@ class TableauSimulator: """ def peek_observable_expectation( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, ) -> int: """Determines the expected value of an observable. @@ -12982,7 +12982,7 @@ class TableauSimulator: """ def postselect_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, desired_value: bool = False, ) -> None: @@ -13241,7 +13241,7 @@ class TableauSimulator: """ def set_inverse_tableau( self, - new_inverse_tableau: stim._stim_polyfill.Tableau, + new_inverse_tableau: stim.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -14165,7 +14165,7 @@ def target_combined_paulis( ''') """ def target_combiner( -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -14207,7 +14207,7 @@ def target_inv( """ def target_logical_observable_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -14268,7 +14268,7 @@ def target_pauli( """ def target_rec( lookback_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -14295,7 +14295,7 @@ def target_rec( """ def target_relative_detector_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -14316,7 +14316,7 @@ def target_relative_detector_id( ''') """ def target_separator( -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -14334,7 +14334,7 @@ def target_separator( """ def target_sweep_bit( sweep_bit_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: diff --git a/glue/python/src/stim/__init__.pyi b/glue/python/src/stim/__init__.pyi index 8ae5519df..d71851394 100644 --- a/glue/python/src/stim/__init__.pyi +++ b/glue/python/src/stim/__init__.pyi @@ -43,8 +43,8 @@ class Circuit: """ def __add__( self, - second: stim._stim_polyfill.Circuit, - ) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, + ) -> stim.Circuit: """Creates a circuit by appending two circuits. Examples: @@ -65,7 +65,7 @@ class Circuit: """ def __eq__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have identical contents. """ @@ -125,8 +125,8 @@ class Circuit: """ def __iadd__( self, - second: stim._stim_polyfill.Circuit, - ) -> stim._stim_polyfill.Circuit: + second: stim.Circuit, + ) -> stim.Circuit: """Appends a circuit into the receiving circuit (mutating it). Examples: @@ -149,7 +149,7 @@ class Circuit: def __imul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Mutates the circuit by putting its contents into a REPEAT block. Special case: if the repetition count is 0, the circuit is cleared. @@ -222,7 +222,7 @@ class Circuit: def __mul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -252,7 +252,7 @@ class Circuit: """ def __ne__( self, - arg0: stim._stim_polyfill.Circuit, + arg0: stim.Circuit, ) -> bool: """Determines if two circuits have non-identical contents. """ @@ -264,7 +264,7 @@ class Circuit: def __rmul__( self, repetitions: int, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Repeats the circuit using a REPEAT block. Has special cases for 0 repetitions and 1 repetitions. @@ -490,7 +490,7 @@ class Circuit: self, *, seed: object = None, - ) -> stim._stim_polyfill.CompiledDetectorSampler: + ) -> stim.CompiledDetectorSampler: """Returns an object that can batch sample detection events from the circuit. Args: @@ -535,7 +535,7 @@ class Circuit: self, *, skip_reference_sample: bool = False, - ) -> stim._stim_polyfill.CompiledMeasurementsToDetectionEventsConverter: + ) -> stim.CompiledMeasurementsToDetectionEventsConverter: """Creates a measurement-to-detection-event converter for the given circuit. The converter can efficiently compute detection events and observable flips @@ -649,7 +649,7 @@ class Circuit: """ def copy( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit. An independent circuit with the same contents. Examples: @@ -761,7 +761,7 @@ class Circuit: """ def decomposed( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set. The intent of this method is to simplify the circuit to use fewer gate types, @@ -961,7 +961,7 @@ class Circuit: approximate_disjoint_errors: float = False, ignore_decomposition_failures: bool = False, block_decomposition_from_introducing_remnant_edges: bool = False, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a stim.DetectorErrorModel describing the error processes in the circuit. Args: @@ -1181,7 +1181,7 @@ class Circuit: *, dem_filter: object = None, reduce_to_one_representative_error: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Explains how detector error model errors are produced by circuit errors. Args: @@ -1234,7 +1234,7 @@ class Circuit: """ def flattened( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Creates an equivalent circuit without REPEAT or SHIFT_COORDS. Returns: @@ -1396,7 +1396,7 @@ class Circuit: before_round_data_depolarization: float = 0.0, before_measure_flip_probability: float = 0.0, after_reset_flip_probability: float = 0.0, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Generates common circuits. The generated circuits can include configurable noise. @@ -1766,7 +1766,7 @@ class Circuit: """ def inverse( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a circuit that applies the same operations but inverted and in reverse. If circuit starts with QUBIT_COORDS instructions, the returned circuit will @@ -2212,7 +2212,7 @@ class Circuit: dont_explore_edges_with_degree_above: int, dont_explore_edges_increasing_symptom_degree: bool, canonicalize_circuit_errors: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Searches for small sets of errors that form an undetectable logical error. THIS IS A HEURISTIC METHOD. It does not guarantee that it will find errors of @@ -2370,7 +2370,7 @@ class Circuit: *, ignore_ungraphlike_errors: bool = True, canonicalize_circuit_errors: bool = False, - ) -> List[stim._stim_polyfill.ExplainedError]: + ) -> List[stim.ExplainedError]: """Finds a minimum set of graphlike errors to produce an undetected logical error. A "graphlike error" is an error that creates at most two detection events @@ -2948,7 +2948,7 @@ class Circuit: """ def with_inlined_feedback( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a circuit without feedback with rewritten detectors/observables. When a feedback operation affects the expected parity of a detector or @@ -3002,7 +3002,7 @@ class Circuit: """ def without_noise( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit with all noise processes removed. Pure noise instructions, such as X_ERROR and DEPOLARIZE2, are not @@ -3029,7 +3029,7 @@ class Circuit: """ def without_tags( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the circuit with all tags removed. Returns: @@ -3074,10 +3074,10 @@ class CircuitErrorLocation: self, *, tick_offset: int, - flipped_pauli_product: List[stim._stim_polyfill.GateTargetWithCoords], + flipped_pauli_product: List[stim.GateTargetWithCoords], flipped_measurement: object, - instruction_targets: stim._stim_polyfill.CircuitTargetsInsideInstruction, - stack_frames: List[stim._stim_polyfill.CircuitErrorLocationStackFrame], + instruction_targets: stim.CircuitTargetsInsideInstruction, + stack_frames: List[stim.CircuitErrorLocationStackFrame], noise_tag: str = '', ) -> None: """Creates a stim.CircuitErrorLocation. @@ -3150,7 +3150,7 @@ class CircuitErrorLocation: @property def flipped_pauli_product( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """The Pauli errors that the error mechanism applied to qubits. When the error is a measurement error, this will be an empty list. @@ -3169,7 +3169,7 @@ class CircuitErrorLocation: @property def instruction_targets( self, - ) -> stim._stim_polyfill.CircuitTargetsInsideInstruction: + ) -> stim.CircuitTargetsInsideInstruction: """Within the error instruction, which may have hundreds of targets, which specific targets were being executed to produce the error. @@ -3213,7 +3213,7 @@ class CircuitErrorLocation: @property def stack_frames( self, - ) -> List[stim._stim_polyfill.CircuitErrorLocationStackFrame]: + ) -> List[stim.CircuitErrorLocationStackFrame]: """Describes where in the circuit's execution the error happened. Multiple frames are needed because the error may occur within a loop, @@ -3397,7 +3397,7 @@ class CircuitInstruction: """ def __eq__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are identical. """ @@ -3441,7 +3441,7 @@ class CircuitInstruction: """ def __ne__( self, - arg0: stim._stim_polyfill.CircuitInstruction, + arg0: stim.CircuitInstruction, ) -> bool: """Determines if two `stim.CircuitInstruction`s are different. """ @@ -3559,7 +3559,7 @@ class CircuitInstruction: """ def targets_copy( self, - ) -> List[stim._stim_polyfill.GateTarget]: + ) -> List[stim.GateTarget]: """Returns a copy of the targets of the instruction. Examples: @@ -3596,14 +3596,14 @@ class CircuitRepeatBlock: """ def __eq__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are identical. """ def __init__( self, repeat_count: int, - body: stim._stim_polyfill.Circuit, + body: stim.Circuit, *, tag: str = '', ) -> None: @@ -3627,7 +3627,7 @@ class CircuitRepeatBlock: """ def __ne__( self, - arg0: stim._stim_polyfill.CircuitRepeatBlock, + arg0: stim.CircuitRepeatBlock, ) -> bool: """Determines if two `stim.CircuitRepeatBlock`s are different. """ @@ -3638,7 +3638,7 @@ class CircuitRepeatBlock: """ def body_copy( self, - ) -> stim._stim_polyfill.Circuit: + ) -> stim.Circuit: """Returns a copy of the body of the repeat block. (Making a copy is enforced to make it clear that editing the result won't change @@ -3752,7 +3752,7 @@ class CircuitTargetsInsideInstruction: args: List[float], target_range_start: int, target_range_end: int, - targets_in_range: List[stim._stim_polyfill.GateTargetWithCoords], + targets_in_range: List[stim.GateTargetWithCoords], ) -> None: """Creates a stim.CircuitTargetsInsideInstruction. @@ -3871,7 +3871,7 @@ class CircuitTargetsInsideInstruction: @property def targets_in_range( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """Returns the subset of targets of the gate/instruction that were being executed. Includes coordinate data with the targets. @@ -3902,8 +3902,8 @@ class CliffordString: """ def __add__( self, - rhs: stim._stim_polyfill.CliffordString, - ) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, + ) -> stim.CliffordString: """Concatenates two CliffordStrings. Args: @@ -3919,7 +3919,7 @@ class CliffordString: """ def __eq__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have identical contents. """ @@ -3967,8 +3967,8 @@ class CliffordString: """ def __iadd__( self, - rhs: stim._stim_polyfill.CliffordString, - ) -> stim._stim_polyfill.CliffordString: + rhs: stim.CliffordString, + ) -> stim.CliffordString: """Mutates the CliffordString by concatenating onto it. Args: @@ -4130,14 +4130,14 @@ class CliffordString: """ def __ne__( self, - arg0: stim._stim_polyfill.CliffordString, + arg0: stim.CliffordString, ) -> bool: """Determines if two Clifford strings have non-identical contents. """ def __pow__( self, power: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns the CliffordString raised to a power. Args: @@ -4178,7 +4178,7 @@ class CliffordString: def __rmul__( self, lhs: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """CliffordString left-multiplication. Args: @@ -4263,7 +4263,7 @@ class CliffordString: """ @staticmethod def all_cliffords_string( - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns a stim.CliffordString containing each single qubit Clifford once. Useful for things like testing that a method works on every single Clifford. @@ -4285,7 +4285,7 @@ class CliffordString: """ def copy( self, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Returns a copy of the CliffordString. Returns: @@ -4305,7 +4305,7 @@ class CliffordString: @staticmethod def random( num_qubits: int, - ) -> stim._stim_polyfill.CliffordString: + ) -> stim.CliffordString: """Samples a uniformly random CliffordString. Args: @@ -4705,7 +4705,7 @@ class CompiledDetectorSampler: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, seed: object = None, ) -> None: @@ -4943,7 +4943,7 @@ class CompiledMeasurementSampler: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, seed: object = None, @@ -5131,7 +5131,7 @@ class CompiledMeasurementsToDetectionEventsConverter: """ def __init__( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, *, skip_reference_sample: bool = False, ) -> None: @@ -5366,7 +5366,7 @@ class DemInstruction: """ def __eq__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have identical contents. """ @@ -5406,7 +5406,7 @@ class DemInstruction: """ def __ne__( self, - arg0: stim._stim_polyfill.DemInstruction, + arg0: stim.DemInstruction, ) -> bool: """Determines if two instructions have non-identical contents. """ @@ -5534,14 +5534,14 @@ class DemRepeatBlock: """ def __eq__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are identical. """ def __init__( self, repeat_count: int, - block: stim._stim_polyfill.DetectorErrorModel, + block: stim.DetectorErrorModel, ) -> None: """Creates a stim.DemRepeatBlock. @@ -5560,7 +5560,7 @@ class DemRepeatBlock: """ def __ne__( self, - arg0: stim._stim_polyfill.DemRepeatBlock, + arg0: stim.DemRepeatBlock, ) -> bool: """Determines if two repeat blocks are different. """ @@ -5571,7 +5571,7 @@ class DemRepeatBlock: """ def body_copy( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the block's body, as a stim.DetectorErrorModel. Examples: @@ -5620,7 +5620,7 @@ class DemTarget: """ def __eq__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are identical. """ @@ -5646,7 +5646,7 @@ class DemTarget: """ def __ne__( self, - arg0: stim._stim_polyfill.DemTarget, + arg0: stim.DemTarget, ) -> bool: """Determines if two `stim.DemTarget`s are different. """ @@ -5714,7 +5714,7 @@ class DemTarget: @staticmethod def logical_observable_id( index: int, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -5737,7 +5737,7 @@ class DemTarget: @staticmethod def relative_detector_id( index: int, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -5759,7 +5759,7 @@ class DemTarget: """ @staticmethod def separator( - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -5814,7 +5814,7 @@ class DemTargetWithCoords: """ def __init__( self, - dem_target: stim._stim_polyfill.DemTarget, + dem_target: stim.DemTarget, coords: List[float], ) -> None: """Creates a stim.DemTargetWithCoords. @@ -5854,7 +5854,7 @@ class DemTargetWithCoords: @property def dem_target( self, - ) -> stim._stim_polyfill.DemTarget: + ) -> stim.DemTarget: """Returns the actual DEM target as a `stim.DemTarget`. Examples: @@ -5932,8 +5932,8 @@ class DetectorErrorModel: """ def __add__( self, - second: stim._stim_polyfill.DetectorErrorModel, - ) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, + ) -> stim.DetectorErrorModel: """Creates a detector error model by appending two models. Examples: @@ -5952,7 +5952,7 @@ class DetectorErrorModel: """ def __eq__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have identical contents. """ @@ -6008,8 +6008,8 @@ class DetectorErrorModel: """ def __iadd__( self, - second: stim._stim_polyfill.DetectorErrorModel, - ) -> stim._stim_polyfill.DetectorErrorModel: + second: stim.DetectorErrorModel, + ) -> stim.DetectorErrorModel: """Appends a detector error model into the receiving model (mutating it). Examples: @@ -6030,7 +6030,7 @@ class DetectorErrorModel: def __imul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Mutates the detector error model by putting its contents into a repeat block. Special case: if the repetition count is 0, the model is cleared. @@ -6097,7 +6097,7 @@ class DetectorErrorModel: def __mul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -6127,7 +6127,7 @@ class DetectorErrorModel: """ def __ne__( self, - arg0: stim._stim_polyfill.DetectorErrorModel, + arg0: stim.DetectorErrorModel, ) -> bool: """Determines if two detector error models have non-identical contents. """ @@ -6139,7 +6139,7 @@ class DetectorErrorModel: def __rmul__( self, repetitions: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Repeats the detector error model using a repeat block. Has special cases for 0 repetitions and 1 repetitions. @@ -6311,7 +6311,7 @@ class DetectorErrorModel: self, *, seed: object = None, - ) -> stim._stim_polyfill.CompiledDemSampler: + ) -> stim.CompiledDemSampler: """Returns a CompiledDemSampler that can batch sample from detector error models. Args: @@ -6371,7 +6371,7 @@ class DetectorErrorModel: """ def copy( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the detector error model. The copy is an independent detector error model with the same contents. @@ -6442,7 +6442,7 @@ class DetectorErrorModel: """ def flattened( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns the detector error model without repeat or detector_shift instructions. Returns: @@ -6623,7 +6623,7 @@ class DetectorErrorModel: def rounded( self, arg0: int, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Creates an equivalent detector error model but with rounded error probabilities. Args: @@ -6659,7 +6659,7 @@ class DetectorErrorModel: def shortest_graphlike_error( self, ignore_ungraphlike_errors: bool = True, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Finds a minimum set of graphlike errors to produce an undetected logical error. Note that this method does not pay attention to error probabilities (other than @@ -6781,7 +6781,7 @@ class DetectorErrorModel: """ def without_tags( self, - ) -> stim._stim_polyfill.DetectorErrorModel: + ) -> stim.DetectorErrorModel: """Returns a copy of the detector error model with all tags removed. Returns: @@ -6825,8 +6825,8 @@ class ExplainedError: def __init__( self, *, - dem_error_terms: List[stim._stim_polyfill.DemTargetWithCoords], - circuit_error_locations: List[stim._stim_polyfill.CircuitErrorLocation], + dem_error_terms: List[stim.DemTargetWithCoords], + circuit_error_locations: List[stim.CircuitErrorLocation], ) -> None: """Creates a stim.ExplainedError. @@ -6855,7 +6855,7 @@ class ExplainedError: @property def circuit_error_locations( self, - ) -> List[stim._stim_polyfill.CircuitErrorLocation]: + ) -> List[stim.CircuitErrorLocation]: """The locations of circuit errors that produce the symptoms in dem_error_terms. Note: if this list contains a single entry, it may be because a result @@ -6888,7 +6888,7 @@ class ExplainedError: @property def dem_error_terms( self, - ) -> List[stim._stim_polyfill.DemTargetWithCoords]: + ) -> List[stim.DemTargetWithCoords]: """The detectors and observables flipped by this error mechanism. """ class FlipSimulator: @@ -7889,7 +7889,7 @@ class FlippedMeasurement: @property def observable( self, - ) -> List[stim._stim_polyfill.GateTargetWithCoords]: + ) -> List[stim.GateTargetWithCoords]: """Returns the observable of the flipped measurement. For example, an `MX 5` measurement will have the observable X5. @@ -7962,7 +7962,7 @@ class Flow: """ def __eq__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have identical contents. """ @@ -8029,8 +8029,8 @@ class Flow: """ def __mul__( self, - rhs: stim._stim_polyfill.Flow, - ) -> stim._stim_polyfill.Flow: + rhs: stim.Flow, + ) -> stim.Flow: """Computes the product of two flows. Args: @@ -8056,7 +8056,7 @@ class Flow: """ def __ne__( self, - arg0: stim._stim_polyfill.Flow, + arg0: stim.Flow, ) -> bool: """Determines if two flows have non-identical contents. """ @@ -8096,7 +8096,7 @@ class Flow: """ def input_copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the flow's input stabilizer. Examples: @@ -8124,7 +8124,7 @@ class Flow: """ def output_copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the flow's output stabilizer. Examples: @@ -8157,7 +8157,7 @@ class GateData: """ def __eq__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are identical. """ @@ -8174,7 +8174,7 @@ class GateData: """ def __ne__( self, - arg0: stim._stim_polyfill.GateData, + arg0: stim.GateData, ) -> bool: """Determines if two GateData instances are not identical. """ @@ -8244,7 +8244,7 @@ class GateData: @property def generalized_inverse( self, - ) -> stim._stim_polyfill.GateData: + ) -> stim.GateData: """The closest-thing-to-an-inverse for the gate, if forced to pick something. The generalized inverse of a unitary gate U is its actual inverse U^-1. @@ -8816,7 +8816,7 @@ class GateTarget: """ def __eq__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are identical. """ @@ -8845,7 +8845,7 @@ class GateTarget: """ def __ne__( self, - arg0: stim._stim_polyfill.GateTarget, + arg0: stim.GateTarget, ) -> bool: """Determines if two `stim.GateTarget`s are different. """ @@ -9168,7 +9168,7 @@ class GateTargetWithCoords: @property def gate_target( self, - ) -> stim._stim_polyfill.GateTarget: + ) -> stim.GateTarget: """Returns the actual gate target as a `stim.GateTarget`. Examples: @@ -9192,8 +9192,8 @@ class PauliString: """ def __add__( self, - rhs: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, + ) -> stim.PauliString: """Returns the tensor product of two Pauli strings. Concatenates the Pauli strings and multiplies their signs. @@ -9215,7 +9215,7 @@ class PauliString: """ def __eq__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have identical contents. """ @@ -9264,8 +9264,8 @@ class PauliString: """ def __iadd__( self, - rhs: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + rhs: stim.PauliString, + ) -> stim.PauliString: """Performs an inplace tensor product. Concatenates the given Pauli string onto the receiving string and multiplies @@ -9291,7 +9291,7 @@ class PauliString: def __imul__( self, rhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Inplace right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9404,7 +9404,7 @@ class PauliString: def __itruediv__( self, rhs: complex, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Inplace divides the Pauli string by a complex unit. Args: @@ -9439,7 +9439,7 @@ class PauliString: def __mul__( self, rhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Right-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9490,13 +9490,13 @@ class PauliString: """ def __ne__( self, - arg0: stim._stim_polyfill.PauliString, + arg0: stim.PauliString, ) -> bool: """Determines if two Pauli strings have non-identical contents. """ def __neg__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the negation of the pauli string. Examples: @@ -9510,7 +9510,7 @@ class PauliString: """ def __pos__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a pauli string with the same contents. Examples: @@ -9530,7 +9530,7 @@ class PauliString: def __rmul__( self, lhs: object, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Left-multiplies the Pauli string. Can multiply by another Pauli string, a complex unit, or a tensor power. @@ -9618,7 +9618,7 @@ class PauliString: def __truediv__( self, rhs: complex, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Divides the Pauli string by a complex unit. Args: @@ -9734,7 +9734,7 @@ class PauliString: """ def commutes( self, - other: stim._stim_polyfill.PauliString, + other: stim.PauliString, ) -> bool: """Determines if two Pauli strings commute or not. @@ -9767,7 +9767,7 @@ class PauliString: """ def copy( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns a copy of the pauli string. The copy is an independent pauli string with the same contents. @@ -9783,8 +9783,8 @@ class PauliString: """ def extended_product( self, - other: stim._stim_polyfill.PauliString, - ) -> Tuple[complex, stim._stim_polyfill.PauliString]: + other: stim.PauliString, + ) -> Tuple[complex, stim.PauliString]: """[DEPRECATED] Use multiplication (__mul__ or *) instead. """ @staticmethod @@ -9897,7 +9897,7 @@ class PauliString: min_weight: int = 0, max_weight: object = None, allowed_paulis: str = 'XYZ', - ) -> stim._stim_polyfill.PauliStringIterator: + ) -> stim.PauliStringIterator: """Returns an iterator that iterates over all matching pauli strings. Args: @@ -9987,7 +9987,7 @@ class PauliString: num_qubits: int, *, allow_imaginary: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Samples a uniformly random Hermitian Pauli string. Args: @@ -10087,7 +10087,7 @@ class PauliString: """ def to_tableau( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Creates a Tableau equivalent to this Pauli string. The tableau represents a Clifford operation that multiplies qubits @@ -10191,7 +10191,7 @@ class PauliStringIterator: """ def __iter__( self, - ) -> stim._stim_polyfill.PauliStringIterator: + ) -> stim.PauliStringIterator: """Returns an independent copy of the pauli string iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -10200,7 +10200,7 @@ class PauliStringIterator: """ def __next__( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the next iterated pauli string. """ class Tableau: @@ -10238,8 +10238,8 @@ class Tableau: """ def __add__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Returns the direct sum (diagonal concatenation) of two Tableaus. Args: @@ -10262,8 +10262,8 @@ class Tableau: """ def __call__( self, - pauli_string: stim._stim_polyfill.PauliString, - ) -> stim._stim_polyfill.PauliString: + pauli_string: stim.PauliString, + ) -> stim.PauliString: """Returns the equivalent PauliString after the Tableau's Clifford operation. If P is a Pauli product before a Clifford operation C, then this method returns @@ -10294,14 +10294,14 @@ class Tableau: """ def __eq__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have identical contents. """ def __iadd__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Performs an inplace direct sum (diagonal concatenation). Args: @@ -10358,8 +10358,8 @@ class Tableau: """ def __mul__( self, - rhs: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + rhs: stim.Tableau, + ) -> stim.Tableau: """Returns the product of two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -10380,14 +10380,14 @@ class Tableau: """ def __ne__( self, - arg0: stim._stim_polyfill.Tableau, + arg0: stim.Tableau, ) -> bool: """Determines if two tableaus have non-identical contents. """ def __pow__( self, exponent: int, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Raises the tableau to an integer power. Large powers are reached efficiently using repeated squaring. @@ -10449,7 +10449,7 @@ class Tableau: """ def copy( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns a copy of the tableau. An independent tableau with the same contents. Examples: @@ -10518,9 +10518,9 @@ class Tableau: @staticmethod def from_conjugated_generators( *, - xs: List[stim._stim_polyfill.PauliString], - zs: List[stim._stim_polyfill.PauliString], - ) -> stim._stim_polyfill.Tableau: + xs: List[stim.PauliString], + zs: List[stim.PauliString], + ) -> stim.Tableau: """Creates a tableau from the given outputs for each generator. Verifies that the tableau is well formed. @@ -10556,7 +10556,7 @@ class Tableau: @staticmethod def from_named_gate( name: str, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns the tableau of a named Clifford gate. Args: @@ -10883,7 +10883,7 @@ class Tableau: self, *, unsigned: bool = False, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Computes the inverse of the tableau. The inverse T^-1 of a tableau T is the unique tableau with the property that @@ -10950,7 +10950,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit X Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).x_output(input_index)`. @@ -11020,7 +11020,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit Y Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).y_output(input_index)`. @@ -11090,7 +11090,7 @@ class Tableau: input_index: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Conjugates a single-qubit Z Pauli generator by the inverse of the tableau. A faster version of `tableau.inverse(unsigned).z_output(input_index)`. @@ -11162,7 +11162,7 @@ class Tableau: num_qubits: int, *, unsigned: bool = False, - ) -> stim._stim_polyfill.TableauIterator: + ) -> stim.TableauIterator: """Returns an iterator that iterates over all Tableaus of a given size. Args: @@ -11212,7 +11212,7 @@ class Tableau: @staticmethod def random( num_qubits: int, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Samples a uniformly random Clifford operation and returns its tableau. Args: @@ -11232,8 +11232,8 @@ class Tableau: """ def then( self, - second: stim._stim_polyfill.Tableau, - ) -> stim._stim_polyfill.Tableau: + second: stim.Tableau, + ) -> stim.Tableau: """Returns the result of composing two tableaus. If the tableau T1 represents the Clifford operation with unitary C1, @@ -11543,7 +11543,7 @@ class Tableau: """ def to_pauli_string( self, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Return a Pauli string equivalent to the tableau. If the tableau is equivalent to a pauli product, creates @@ -11575,7 +11575,7 @@ class Tableau: self, *, canonicalize: bool = False, - ) -> List[stim._stim_polyfill.PauliString]: + ) -> List[stim.PauliString]: """Returns the stabilizer generators of the tableau, optionally canonicalized. The stabilizer generators of the tableau are its Z outputs. Canonicalizing @@ -11720,7 +11720,7 @@ class Tableau: def x_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli X by the tableau's Clifford operation. Args: @@ -11795,7 +11795,7 @@ class Tableau: def y_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli Y by the tableau's Clifford operation. Args: @@ -11872,7 +11872,7 @@ class Tableau: def z_output( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the result of conjugating a Pauli Z by the tableau's Clifford operation. Args: @@ -11958,7 +11958,7 @@ class TableauIterator: """ def __iter__( self, - ) -> stim._stim_polyfill.TableauIterator: + ) -> stim.TableauIterator: """Returns an independent copy of the tableau iterator. Since for-loops and loop-comprehensions call `iter` on things they @@ -11967,7 +11967,7 @@ class TableauIterator: """ def __next__( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns the next iterated tableau. """ class TableauSimulator: @@ -12091,7 +12091,7 @@ class TableauSimulator: """ def canonical_stabilizers( self, - ) -> List[stim._stim_polyfill.PauliString]: + ) -> List[stim.PauliString]: """Returns a standardized list of the simulator's current stabilizer generators. Two simulators have the same canonical stabilizers if and only if their current @@ -12237,7 +12237,7 @@ class TableauSimulator: """ def current_inverse_tableau( self, - ) -> stim._stim_polyfill.Tableau: + ) -> stim.Tableau: """Returns a copy of the internal state of the simulator as a stim.Tableau. Returns: @@ -12427,7 +12427,7 @@ class TableauSimulator: """ def do_circuit( self, - circuit: stim._stim_polyfill.Circuit, + circuit: stim.Circuit, ) -> None: """Applies a circuit to the simulator's state. @@ -12446,7 +12446,7 @@ class TableauSimulator: """ def do_pauli_string( self, - pauli_string: stim._stim_polyfill.PauliString, + pauli_string: stim.PauliString, ) -> None: """Applies the paulis from a pauli string to the simulator's state. @@ -12462,7 +12462,7 @@ class TableauSimulator: """ def do_tableau( self, - tableau: stim._stim_polyfill.Tableau, + tableau: stim.Tableau, targets: List[int], ) -> None: """Applies a custom tableau operation to qubits in the simulator. @@ -12735,7 +12735,7 @@ class TableauSimulator: """ def measure_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, flip_probability: float = 0.0, ) -> bool: @@ -12792,7 +12792,7 @@ class TableauSimulator: def peek_bloch( self, target: int, - ) -> stim._stim_polyfill.PauliString: + ) -> stim.PauliString: """Returns the state of the qubit as a single-qubit stim.PauliString stabilizer. This is a non-physical operation. It reports information about the qubit without @@ -12837,7 +12837,7 @@ class TableauSimulator: """ def peek_observable_expectation( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, ) -> int: """Determines the expected value of an observable. @@ -12982,7 +12982,7 @@ class TableauSimulator: """ def postselect_observable( self, - observable: stim._stim_polyfill.PauliString, + observable: stim.PauliString, *, desired_value: bool = False, ) -> None: @@ -13241,7 +13241,7 @@ class TableauSimulator: """ def set_inverse_tableau( self, - new_inverse_tableau: stim._stim_polyfill.Tableau, + new_inverse_tableau: stim.Tableau, ) -> None: """Overwrites the simulator's internal state with the given inverse tableau. @@ -14165,7 +14165,7 @@ def target_combined_paulis( ''') """ def target_combiner( -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a target combiner that can be used to build Pauli products. Examples: @@ -14207,7 +14207,7 @@ def target_inv( """ def target_logical_observable_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a logical observable id identifying a frame change. Args: @@ -14268,7 +14268,7 @@ def target_pauli( """ def target_rec( lookback_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a measurement record target with the given lookback. Measurement record targets are used to refer back to the measurement record; @@ -14295,7 +14295,7 @@ def target_rec( """ def target_relative_detector_id( index: int, -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a relative detector id (e.g. "D5" in a .dem file). Args: @@ -14316,7 +14316,7 @@ def target_relative_detector_id( ''') """ def target_separator( -) -> stim._stim_polyfill.DemTarget: +) -> stim.DemTarget: """Returns a target separator (e.g. "^" in a .dem file). Examples: @@ -14334,7 +14334,7 @@ def target_separator( """ def target_sweep_bit( sweep_bit_index: int, -) -> stim._stim_polyfill.GateTarget: +) -> stim.GateTarget: """Returns a sweep bit target that can be passed into `stim.Circuit.append`. Args: From 7fd38e970d77346565cca843efe485e79d76277d Mon Sep 17 00:00:00 2001 From: Adam Zalcman Date: Wed, 21 Jan 2026 02:16:45 +0000 Subject: [PATCH 10/10] 5 -> 5.00 --- doc/sinter_api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sinter_api.md b/doc/sinter_api.md index a29c5b19c..5cb64f821 100644 --- a/doc/sinter_api.md +++ b/doc/sinter_api.md @@ -852,7 +852,7 @@ def to_csv_line( >>> print(sinter.CSV_HEADER) shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts >>> print(stat.to_csv_line()) - 22, 3, 0, 5,pymatching,test,"{""a"":[1,2,3]}", + 22, 3, 0, 5.00,pymatching,test,"{""a"":[1,2,3]}", """ ```