Skip to content

Commit

Permalink
type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Mar 12, 2024
1 parent f5d53cb commit 1f05663
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/python_api_reference_vDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -1281,8 +1281,8 @@ def count_determined_measurements(
def detecting_regions(
self,
*,
included_targets: Iterable[Iterable[float] | str | stim.DemTarget] | None = None,
included_ticks: None | Iterable[int] = None,
targets: Optional[Iterable[stim.DemTarget | str | Iterable[float]]] = None,
ticks: Optional[Iterable[int]] = None,
) -> Dict[stim.DemTarget, Dict[int, stim.PauliString]]:
"""Records where detectors and observables are sensitive to errors over time.
Expand Down
4 changes: 2 additions & 2 deletions doc/stim.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ class Circuit:
def detecting_regions(
self,
*,
included_targets: Iterable[Iterable[float] | str | stim.DemTarget] | None = None,
included_ticks: None | Iterable[int] = None,
targets: Optional[Iterable[stim.DemTarget | str | Iterable[float]]] = None,
ticks: Optional[Iterable[int]] = None,
) -> Dict[stim.DemTarget, Dict[int, stim.PauliString]]:
"""Records where detectors and observables are sensitive to errors over time.
Expand Down
4 changes: 2 additions & 2 deletions glue/python/src/stim/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ class Circuit:
def detecting_regions(
self,
*,
included_targets: Iterable[Iterable[float] | str | stim.DemTarget] | None = None,
included_ticks: None | Iterable[int] = None,
targets: Optional[Iterable[stim.DemTarget | str | Iterable[float]]] = None,
ticks: Optional[Iterable[int]] = None,
) -> Dict[stim.DemTarget, Dict[int, stim.PauliString]]:
"""Records where detectors and observables are sensitive to errors over time.
Expand Down
2 changes: 1 addition & 1 deletion src/stim/circuit/circuit.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ void stim_pybind::pybind_circuit_methods(pybind11::module &, pybind11::class_<Ci
pybind11::arg("ticks") = pybind11::none(),
pybind11::arg("ignore_anticommutation_errors") = false,
clean_doc_string(R"DOC(
@signature def detecting_regions(self, *, included_targets: Iterable[Iterable[float] | str | stim.DemTarget] | None = None, included_ticks: None | Iterable[int] = None) -> Dict[stim.DemTarget, Dict[int, stim.PauliString]]:
@signature def detecting_regions(self, *, targets: Optional[Iterable[stim.DemTarget | str | Iterable[float]]] = None, ticks: Optional[Iterable[int]] = None) -> Dict[stim.DemTarget, Dict[int, stim.PauliString]]:
Records where detectors and observables are sensitive to errors over time.
The result of this method is a nested dictionary, mapping detectors/observables
Expand Down
10 changes: 10 additions & 0 deletions src/stim/circuit/circuit_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,3 +1714,13 @@ def test_detecting_regions():
1: stim.PauliString("X_"),
2: stim.PauliString("XX"),
}}


def test_detecting_region_filters():
c = stim.Circuit.generated("repetition_code:memory", distance=3, rounds=3)
assert len(c.detecting_regions(targets=["D"])) == c.num_detectors
assert len(c.detecting_regions(targets=["L"])) == c.num_observables
assert len(c.detecting_regions()) == c.num_observables + c.num_detectors
assert len(c.detecting_regions(targets=["D0"])) == 1
assert len(c.detecting_regions(targets=["D0", "L0"])) == 2
assert len(c.detecting_regions(targets=[stim.target_relative_detector_id(0), "D0"])) == 1

0 comments on commit 1f05663

Please sign in to comment.