From 824e2869cfd5e28182c303933fe75e054466d912 Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Thu, 30 Jan 2025 16:23:28 -0800 Subject: [PATCH] type fix and various missing example warnings fixed --- doc/python_api_reference_vDev.md | 20 +- doc/stim.pyi | 20 +- glue/python/src/stim/__init__.pyi | 20 +- src/stim/circuit/circuit.pybind.cc | 18 +- src/stim/search/sat/wcnf.cc | 4 +- src/stim/search/sat/wcnf.h | 8 +- src/stim/simulators/frame_simulator.pybind.cc | 23 +- .../simulators/tableau_simulator.pybind.cc | 348 ++++++++++++++++++ 8 files changed, 427 insertions(+), 34 deletions(-) diff --git a/doc/python_api_reference_vDev.md b/doc/python_api_reference_vDev.md index 8092bb3a0..913af79e8 100644 --- a/doc/python_api_reference_vDev.md +++ b/doc/python_api_reference_vDev.md @@ -8259,7 +8259,7 @@ def to_numpy( output_measure_flips: bool | np.ndarray = False, output_detector_flips: bool | np.ndarray = False, output_observable_flips: bool | np.ndarray = False, -) -> Tuple[np.ndarray, np.ndarray]: +) -> Optional[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]: """Writes the simulator state into numpy arrays. Args: @@ -8366,16 +8366,18 @@ def to_numpy( Examples: >>> import stim >>> sim = stim.FlipSimulator(batch_size=9) - >>> sim.do(stim.Circuit('M 0 1 2')) + >>> sim.do(stim.Circuit('M(1) 0 1 2')) + >>> ms_buf = np.empty(shape=(9, 1), dtype=np.uint8) >>> xs, zs, ms, ds, os = sim.to_numpy( ... transpose=True, ... bit_packed=True, - ... output_measure_flips=True, + ... output_zs=True, + ... output_measure_flips=ms_buf, ... ) + >>> assert ms is ms_buf >>> xs >>> zs - >>> ms array([[0], [0], [0], @@ -8385,6 +8387,16 @@ def to_numpy( [0], [0], [0]], dtype=uint8) + >>> ms + array([[7], + [7], + [7], + [7], + [7], + [7], + [7], + [7], + [7]], dtype=uint8) >>> ds >>> os """ diff --git a/doc/stim.pyi b/doc/stim.pyi index a02634064..f144d39c4 100644 --- a/doc/stim.pyi +++ b/doc/stim.pyi @@ -6519,7 +6519,7 @@ class FlipSimulator: output_measure_flips: bool | np.ndarray = False, output_detector_flips: bool | np.ndarray = False, output_observable_flips: bool | np.ndarray = False, - ) -> Tuple[np.ndarray, np.ndarray]: + ) -> Optional[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]: """Writes the simulator state into numpy arrays. Args: @@ -6626,16 +6626,18 @@ class FlipSimulator: Examples: >>> import stim >>> sim = stim.FlipSimulator(batch_size=9) - >>> sim.do(stim.Circuit('M 0 1 2')) + >>> sim.do(stim.Circuit('M(1) 0 1 2')) + >>> ms_buf = np.empty(shape=(9, 1), dtype=np.uint8) >>> xs, zs, ms, ds, os = sim.to_numpy( ... transpose=True, ... bit_packed=True, - ... output_measure_flips=True, + ... output_zs=True, + ... output_measure_flips=ms_buf, ... ) + >>> assert ms is ms_buf >>> xs >>> zs - >>> ms array([[0], [0], [0], @@ -6645,6 +6647,16 @@ class FlipSimulator: [0], [0], [0]], dtype=uint8) + >>> ms + array([[7], + [7], + [7], + [7], + [7], + [7], + [7], + [7], + [7]], dtype=uint8) >>> ds >>> os """ diff --git a/glue/python/src/stim/__init__.pyi b/glue/python/src/stim/__init__.pyi index a02634064..f144d39c4 100644 --- a/glue/python/src/stim/__init__.pyi +++ b/glue/python/src/stim/__init__.pyi @@ -6519,7 +6519,7 @@ class FlipSimulator: output_measure_flips: bool | np.ndarray = False, output_detector_flips: bool | np.ndarray = False, output_observable_flips: bool | np.ndarray = False, - ) -> Tuple[np.ndarray, np.ndarray]: + ) -> Optional[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]: """Writes the simulator state into numpy arrays. Args: @@ -6626,16 +6626,18 @@ class FlipSimulator: Examples: >>> import stim >>> sim = stim.FlipSimulator(batch_size=9) - >>> sim.do(stim.Circuit('M 0 1 2')) + >>> sim.do(stim.Circuit('M(1) 0 1 2')) + >>> ms_buf = np.empty(shape=(9, 1), dtype=np.uint8) >>> xs, zs, ms, ds, os = sim.to_numpy( ... transpose=True, ... bit_packed=True, - ... output_measure_flips=True, + ... output_zs=True, + ... output_measure_flips=ms_buf, ... ) + >>> assert ms is ms_buf >>> xs >>> zs - >>> ms array([[0], [0], [0], @@ -6645,6 +6647,16 @@ class FlipSimulator: [0], [0], [0]], dtype=uint8) + >>> ms + array([[7], + [7], + [7], + [7], + [7], + [7], + [7], + [7], + [7]], dtype=uint8) >>> ds >>> os """ diff --git a/src/stim/circuit/circuit.pybind.cc b/src/stim/circuit/circuit.pybind.cc index f6f133c26..4f3fc640f 100644 --- a/src/stim/circuit/circuit.pybind.cc +++ b/src/stim/circuit/circuit.pybind.cc @@ -169,12 +169,12 @@ std::vector py_find_undetectable_logical_error( return ErrorMatcher::explain_errors_from_circuit(self, &filter, reduce_to_representative); } -std::string py_shortest_error_sat_problem(const Circuit &self, std::string format) { +std::string py_shortest_error_sat_problem(const Circuit &self, std::string_view format) { DetectorErrorModel dem = ErrorAnalyzer::circuit_to_detector_error_model(self, false, true, false, 1, false, false); return stim::shortest_error_sat_problem(dem, format); } -std::string py_likeliest_error_sat_problem(const Circuit &self, int quantization, std::string format) { +std::string py_likeliest_error_sat_problem(const Circuit &self, int quantization, std::string_view format) { DetectorErrorModel dem = ErrorAnalyzer::circuit_to_detector_error_model(self, false, true, false, 1, false, false); return stim::likeliest_error_sat_problem(dem, quantization, format); } @@ -255,7 +255,7 @@ void circuit_append( std::vector raw_targets; try { raw_targets.push_back(obj_to_gate_target(targets).data); - } catch (const std::invalid_argument &ex) { + } catch (const std::invalid_argument &) { for (const auto &t : targets) { raw_targets.push_back(handle_to_gate_target(t).data); } @@ -279,13 +279,13 @@ void circuit_append( auto d = pybind11::cast(used_arg); self.safe_append_ua(gate_name, raw_targets, d, tag); return; - } catch (const pybind11::cast_error &ex) { + } catch (const pybind11::cast_error &) { } try { auto args = pybind11::cast>(used_arg); self.safe_append_u(gate_name, raw_targets, args, tag); return; - } catch (const pybind11::cast_error &ex) { + } catch (const pybind11::cast_error &) { } throw std::invalid_argument("Arg must be a double or sequence of doubles."); } else if (pybind11::isinstance(obj)) { @@ -1329,8 +1329,8 @@ void stim_pybind::pybind_circuit_methods(pybind11::module &, pybind11::class_ bool { try { return self.approx_equals(pybind11::cast(obj), atol); - } catch (const pybind11::cast_error &ex) { + } catch (const pybind11::cast_error &) { return false; } }, diff --git a/src/stim/search/sat/wcnf.cc b/src/stim/search/sat/wcnf.cc index aec6e423f..8f9577cfa 100644 --- a/src/stim/search/sat/wcnf.cc +++ b/src/stim/search/sat/wcnf.cc @@ -260,14 +260,14 @@ std::string sat_problem_as_wcnf_string(const DetectorErrorModel& model, bool wei } // Should ignore weights entirely and minimize the cardinality. -std::string stim::shortest_error_sat_problem(const DetectorErrorModel& model, std::string format) { +std::string stim::shortest_error_sat_problem(const DetectorErrorModel& model, std::string_view format) { if (format != "WDIMACS") { throw std::invalid_argument("Unsupported format."); } return sat_problem_as_wcnf_string(model, /*weighted=*/false, /*quantization=*/0); } -std::string stim::likeliest_error_sat_problem(const DetectorErrorModel& model, int quantization, std::string format) { +std::string stim::likeliest_error_sat_problem(const DetectorErrorModel& model, int quantization, std::string_view format) { if (format != "WDIMACS") { throw std::invalid_argument("Unsupported format."); } diff --git a/src/stim/search/sat/wcnf.h b/src/stim/search/sat/wcnf.h index e57d0d853..82c00cc3e 100644 --- a/src/stim/search/sat/wcnf.h +++ b/src/stim/search/sat/wcnf.h @@ -1,8 +1,6 @@ #ifndef _STIM_SEARCH_SAT_WCNF_H #define _STIM_SEARCH_SAT_WCNF_H -#include - #include "stim/dem/detector_error_model.h" namespace stim { @@ -33,13 +31,11 @@ namespace stim { /// users must separately manage the process of selecting and running the solver. This approach is designed to /// sidestep the need for direct integration with any particular solver and allow /// for experimentation with different solvers to achieve the best performance. -// std::string shortest_error_problem_as_wcnf_file( -// const DetectorErrorModel &model, bool weighted=false, size_t weight_scale_factor=0); -std::string shortest_error_sat_problem(const DetectorErrorModel& model, std::string format = "WDIMACS"); +std::string shortest_error_sat_problem(const DetectorErrorModel& model, std::string_view format = "WDIMACS"); std::string likeliest_error_sat_problem( - const DetectorErrorModel& model, int quantization = 10, std::string format = "WDIMACS"); + const DetectorErrorModel& model, int quantization = 10, std::string_view format = "WDIMACS"); } // namespace stim diff --git a/src/stim/simulators/frame_simulator.pybind.cc b/src/stim/simulators/frame_simulator.pybind.cc index 718883009..f5dbd993e 100644 --- a/src/stim/simulators/frame_simulator.pybind.cc +++ b/src/stim/simulators/frame_simulator.pybind.cc @@ -613,7 +613,7 @@ void stim_pybind::pybind_frame_simulator_methods( pybind11::arg("output_detector_flips") = false, pybind11::arg("output_observable_flips") = false, clean_doc_string(R"DOC( - @signature def to_numpy(self, *, bit_packed: bool = False, transpose: bool = False, output_xs: bool | np.ndarray = False, output_zs: bool | np.ndarray = False, output_measure_flips: bool | np.ndarray = False, output_detector_flips: bool | np.ndarray = False, output_observable_flips: bool | np.ndarray = False) -> tuple[np.ndarray, np.ndarray]: + @signature def to_numpy(self, *, bit_packed: bool = False, transpose: bool = False, output_xs: bool | np.ndarray = False, output_zs: bool | np.ndarray = False, output_measure_flips: bool | np.ndarray = False, output_detector_flips: bool | np.ndarray = False, output_observable_flips: bool | np.ndarray = False) -> Optional[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]: Writes the simulator state into numpy arrays. Args: @@ -719,17 +719,19 @@ void stim_pybind::pybind_frame_simulator_methods( Examples: >>> import stim + >>> import numpy as np >>> sim = stim.FlipSimulator(batch_size=9) - >>> sim.do(stim.Circuit('M 0 1 2')) + >>> sim.do(stim.Circuit('M(1) 0 1 2')) + >>> ms_buf = np.empty(shape=(9, 1), dtype=np.uint8) >>> xs, zs, ms, ds, os = sim.to_numpy( ... transpose=True, ... bit_packed=True, - ... output_measure_flips=True, + ... output_xs=True, + ... output_measure_flips=ms_buf, ... ) + >>> assert ms is ms_buf >>> xs - >>> zs - >>> ms array([[0], [0], [0], @@ -739,6 +741,17 @@ void stim_pybind::pybind_frame_simulator_methods( [0], [0], [0]], dtype=uint8) + >>> zs + >>> ms + array([[7], + [7], + [7], + [7], + [7], + [7], + [7], + [7], + [7]], dtype=uint8) >>> ds >>> os )DOC") diff --git a/src/stim/simulators/tableau_simulator.pybind.cc b/src/stim/simulators/tableau_simulator.pybind.cc index 58e3427ff..bd916a3d9 100644 --- a/src/stim/simulators/tableau_simulator.pybind.cc +++ b/src/stim/simulators/tableau_simulator.pybind.cc @@ -711,6 +711,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.c_xyz(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +Y +Z +X )DOC") .data()); @@ -725,6 +737,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.c_zyx(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +Z +X +Y )DOC") .data()); @@ -739,6 +763,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.h_xy(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +Y +X -Z )DOC") .data()); @@ -753,6 +789,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.h_yz(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + -X +Z +Y )DOC") .data()); @@ -766,6 +814,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.x(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X -Y -Z )DOC") .data()); @@ -779,6 +839,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.y(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + -X +Y -Z )DOC") .data()); @@ -792,6 +864,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.z(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + -X -Y +Z )DOC") .data()); @@ -805,6 +889,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.s(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +Y -X +Z )DOC") .data()); @@ -819,6 +915,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.s_dag(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + -Y +X +Z )DOC") .data()); @@ -833,6 +941,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.sqrt_x(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Z -Y )DOC") .data()); @@ -847,6 +967,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.sqrt_x_dag(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X -Z +Y )DOC") .data()); @@ -861,6 +993,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.sqrt_y(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + -Z +Y +X )DOC") .data()); @@ -875,6 +1019,18 @@ void stim_pybind::pybind_tableau_simulator_methods( Args: *targets: The indices of the qubits to target with the gate. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +X +Y +Z + >>> s.sqrt_y_dag(0, 1, 2) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(3))) + +Z +Y -X )DOC") .data()); @@ -890,6 +1046,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.swap(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +Y +X +X +Z )DOC") .data()); @@ -905,6 +1073,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.iswap(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Y +Z )DOC") .data()); @@ -921,6 +1101,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.iswap_dag(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ -Y +Z )DOC") .data()); @@ -936,6 +1128,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.cnot(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -951,6 +1155,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.zcx(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -966,6 +1182,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.cx(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -981,6 +1209,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.cz(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -996,6 +1236,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.zcz(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -1011,6 +1263,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.cy(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X )DOC") .data()); @@ -1026,6 +1290,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.zcy(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X )DOC") .data()); @@ -1041,6 +1317,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.xcx(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X )DOC") .data()); @@ -1056,6 +1344,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.xcy(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +_ +_ )DOC") .data()); @@ -1071,6 +1371,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.xcz(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +_ +_ )DOC") .data()); @@ -1086,6 +1398,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.ycx(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +Z +X )DOC") .data()); @@ -1101,6 +1425,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.ycy(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +_ +_ )DOC") .data()); @@ -1116,6 +1452,18 @@ void stim_pybind::pybind_tableau_simulator_methods( *targets: The indices of the qubits to target with the gate. Applies the gate to the first two targets, then the next two targets, and so forth. There must be an even number of targets. + + Examples: + >>> import stim + >>> s = stim.TableauSimulator() + >>> s.reset_x(0, 3) + >>> s.reset_y(1) + + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +X +Y +Z +X + >>> s.ycz(0, 1, 2, 3) + >>> print(" ".join(str(s.peek_bloch(k)) for k in range(4))) + +_ +_ +_ +_ )DOC") .data());