Skip to content

Commit d5e973d

Browse files
authored
fix strip_undecomposable_errors flag in decompose_errors. (#223)
Decompose errors still fails on logically inconsistent errors because I forgot to bypass that valueerror, adding it here.
1 parent 764483a commit d5e973d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/py/_tesseract_py_util/decompose_errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ def decompose_errors_using_detector_assignment(
185185
)
186186

187187
if consistent_obs_by_component is None:
188+
if strip_undecomposable_errors:
189+
continue
188190
raise ValueError(
189191
f"The error instruction `{instruction}` could not be decomposed, due to its "
190192
"observables not being consistent with the observables of any available "

src/py/_tesseract_py_util/decompose_errors_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ def test_decompose_errors_strip_undecomposable_errors():
211211
assert str(decomposed_dem) == str(expected_dem)
212212

213213

214+
215+
216+
def test_decompose_errors_strip_inconsistent_observables():
217+
dem = stim.DetectorErrorModel("""
218+
detector(0) D0
219+
detector(1) D1
220+
# Standalone components fix observable choices for each detector.
221+
error(0.1) D0 L0
222+
error(0.1) D1 L1
223+
# Cross-component error has observables that cannot be matched by available components.
224+
error(0.1) D0 D1 L0
225+
""")
226+
227+
with pytest.raises(ValueError, match="could not be decomposed"):
228+
decompose_errors_using_last_coordinate_index(dem)
229+
230+
decomposed_dem = decompose_errors_using_last_coordinate_index(
231+
dem, strip_undecomposable_errors=True
232+
)
233+
234+
expected_dem = stim.DetectorErrorModel("""
235+
detector(0) D0
236+
detector(1) D1
237+
error(0.1) D0 L0
238+
error(0.1) D1 L1
239+
""")
240+
assert str(decomposed_dem) == str(expected_dem)
241+
214242
def test_undecompose_errors_with_repeat_block():
215243
dem = stim.DetectorErrorModel("""error(0.1) D2 D5 ^ D10 L1
216244
repeat 10 {

0 commit comments

Comments
 (0)