@@ -170,13 +170,15 @@ This repository contains the C++ implementation of the Tesseract quantum error c
170170The following example demonstrates how to create and use the Tesseract decoder using the Python interface.
171171
172172``` python
173- import tesseract_decoder.tesseract as tesseract
173+ from tesseract_decoder import tesseract
174174import stim
175+ import numpy as np
176+
175177
176178# 1. Define a detector error model (DEM)
177179dem = stim.DetectorErrorModel("""
178- error(0.1) D0 D1
179- error(0.2) D1 D2 L0
180+ error(0.1) D0 D1 L0
181+ error(0.2) D1 D2 L1
180182 detector(0, 0, 0) D0
181183 detector(1, 0, 0) D1
182184 detector(2, 0, 0) D2
@@ -185,15 +187,24 @@ dem = stim.DetectorErrorModel("""
185187# 2. Create the decoder configuration
186188config = tesseract.TesseractConfig(dem = dem, det_beam = 50 )
187189
188- # 3. Configure and create a decoder instance
189- decoder = tesseract.TesseractDecoder(config )
190+ # 3. Create a decoder instance
191+ decoder = config.compile_decoder( )
190192
191- # 4. Simulate detection events and decode it
192- detections = [1 , 2 ]
193- flipped_observables = decoder.decode(detections)
193+ # 4. Simulate detection events
194+ syndrome = [0 , 1 , 1 ]
194195
195- print (f " Detections: { detections} " )
196+ # 5a. Decode to observables
197+ flipped_observables = decoder.decode(syndrome)
196198print (f " Flipped observables: { flipped_observables} " )
199+
200+ # 5b. Alternatively, decode to errors
201+ decoder.decode_to_errors(np.where(syndrome)[0 ])
202+ predicted_errors = decoder.predicted_errors_buffer
203+ # Indices of predicted errors
204+ print (f " Predicted errors indices: { predicted_errors} " )
205+ # Print properties of predicted errors
206+ for i in predicted_errors:
207+ print (f " { i} : { decoder.errors[i]} " )
197208```
198209
199210
0 commit comments