Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/py/_tesseract_py_util/decompose_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def decompose_errors_using_detector_assignment(
)

if consistent_obs_by_component is None:
if strip_undecomposable_errors:
continue
raise ValueError(
f"The error instruction `{instruction}` could not be decomposed, due to its "
"observables not being consistent with the observables of any available "
Expand Down
28 changes: 28 additions & 0 deletions src/py/_tesseract_py_util/decompose_errors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,34 @@ def test_decompose_errors_strip_undecomposable_errors():
assert str(decomposed_dem) == str(expected_dem)




def test_decompose_errors_strip_inconsistent_observables():
dem = stim.DetectorErrorModel("""
detector(0) D0
detector(1) D1
# Standalone components fix observable choices for each detector.
error(0.1) D0 L0
error(0.1) D1 L1
# Cross-component error has observables that cannot be matched by available components.
error(0.1) D0 D1 L0
""")

with pytest.raises(ValueError, match="could not be decomposed"):
decompose_errors_using_last_coordinate_index(dem)

decomposed_dem = decompose_errors_using_last_coordinate_index(
dem, strip_undecomposable_errors=True
)

expected_dem = stim.DetectorErrorModel("""
detector(0) D0
detector(1) D1
error(0.1) D0 L0
error(0.1) D1 L1
""")
assert str(decomposed_dem) == str(expected_dem)

def test_undecompose_errors_with_repeat_block():
dem = stim.DetectorErrorModel("""error(0.1) D2 D5 ^ D10 L1
repeat 10 {
Expand Down
Loading