@@ -48,14 +48,18 @@ def test_create_node():
4848
4949
5050def test_create_tesseract_config ():
51- assert (
52- str (tesseract_decoder .tesseract .TesseractConfig (_DETECTOR_ERROR_MODEL ))
53- == "TesseractConfig(dem=DetectorErrorModel_Object, det_beam=65535, no_revisit_dets=0, at_most_two_errors_per_detector=0, verbose=0, merge_errors=1, pqlimit=18446744073709551615, det_orders=[], det_penalty=0, create_visualization=0)"
54- )
55- assert (
56- tesseract_decoder .tesseract .TesseractConfig (_DETECTOR_ERROR_MODEL ).dem
57- == _DETECTOR_ERROR_MODEL
58- )
51+ config = tesseract_decoder .tesseract .TesseractConfig (_DETECTOR_ERROR_MODEL )
52+ assert config .dem == _DETECTOR_ERROR_MODEL
53+ assert config .det_beam == 5
54+ assert config .no_revisit_dets is True
55+ assert config .at_most_two_errors_per_detector is False
56+ assert config .verbose is False
57+ assert config .merge_errors is True
58+ assert config .pqlimit == 200000
59+ assert config .det_penalty == 0
60+ assert config .create_visualization is False
61+ assert len (config .det_orders ) == 20
62+
5963
6064def test_create_tesseract_config_with_dem ():
6165 """
@@ -64,14 +68,16 @@ def test_create_tesseract_config_with_dem():
6468
6569 config = tesseract_decoder .tesseract .TesseractConfig (_DETECTOR_ERROR_MODEL )
6670
67- # Assert the string representation matches the expected format.
68- assert (
69- str (config )
70- == "TesseractConfig(dem=DetectorErrorModel_Object, det_beam=65535, no_revisit_dets=0, at_most_two_errors_per_detector=0, verbose=0, merge_errors=1, pqlimit=18446744073709551615, det_orders=[], det_penalty=0, create_visualization=0)"
71- )
72-
73- # Assert that the `dem` attribute is correctly set.
7471 assert config .dem == _DETECTOR_ERROR_MODEL
72+ assert config .det_beam == 5
73+ assert config .no_revisit_dets is True
74+ assert config .at_most_two_errors_per_detector is False
75+ assert config .verbose is False
76+ assert config .merge_errors is True
77+ assert config .pqlimit == 200000
78+ assert config .det_penalty == 0
79+ assert config .create_visualization is False
80+ assert len (config .det_orders ) == 20
7581
7682def test_create_tesseract_config_with_dem_and_custom_args ():
7783 """
@@ -85,17 +91,17 @@ def test_create_tesseract_config_with_dem_and_custom_args():
8591 det_penalty = 0.5
8692 )
8793
88- # Assert that the `dem` and custom arguments are correctly set.
8994 assert config .dem == _DETECTOR_ERROR_MODEL
9095 assert config .det_beam == 100
96+ assert config .no_revisit_dets is True
97+ assert config .at_most_two_errors_per_detector is False
98+ assert config .verbose is False
9199 assert config .merge_errors is False
100+ assert config .pqlimit == 200000
92101 assert config .det_penalty == 0.5
102+ assert config .create_visualization is False
103+ assert len (config .det_orders ) == 20
93104
94- # Assert the string representation is as expected.
95- assert (
96- str (config )
97- == "TesseractConfig(dem=DetectorErrorModel_Object, det_beam=100, no_revisit_dets=0, at_most_two_errors_per_detector=0, verbose=0, merge_errors=0, pqlimit=18446744073709551615, det_orders=[], det_penalty=0.5, create_visualization=0)"
98- )
99105
100106def test_compile_decoder_for_dem_basic_functionality ():
101107 """
@@ -156,37 +162,34 @@ def test_create_tesseract_config_no_dem():
156162 Tests the new constructor that does not require a `dem` argument.
157163 """
158164 # Create an instance with no arguments.
159- config_default = tesseract_decoder .tesseract .TesseractConfig ()
160-
161- # Assert that the ` dem` attribute defaults to an empty DetectorErrorModel.
162- empty_dem = stim . DetectorErrorModel ()
163- assert config_default . dem == empty_dem
164-
165- # Assert that the string representation shows the default values.
166- assert (
167- str ( config_default )
168- == "TesseractConfig(dem=DetectorErrorModel_Object, det_beam=65535, no_revisit_dets=0, at_most_two_errors_per_detector=0, verbose=0, merge_errors=1, pqlimit=18446744073709551615, det_orders=[], det_penalty=0, create_visualization=0)"
169- )
165+ config = tesseract_decoder .tesseract .TesseractConfig ()
166+
167+ assert config . dem == stim . DetectorErrorModel ()
168+ assert config . det_beam == 5
169+ assert config . no_revisit_dets is True
170+ assert config . at_most_two_errors_per_detector is False
171+ assert config . verbose is False
172+ assert config . merge_errors is True
173+ assert config . pqlimit == 200000
174+ assert config . det_penalty == 0.0
175+ assert config . create_visualization is False
170176
171177def test_create_tesseract_config_no_dem_with_custom_args ():
172178 """
173179 Tests the new constructor with custom arguments to ensure they are passed correctly.
174180 """
175181 # Create an instance with no dem but a custom det_beam.
176- config_custom = tesseract_decoder .tesseract .TesseractConfig (det_beam = 15 , verbose = True )
177-
178- # Assert that the `det_beam` and `verbose` attributes are correctly set.
179- assert config_custom .det_beam == 15
180- assert config_custom .verbose is True
181-
182- # Assert that the `dem` attribute still defaults to an empty DetectorErrorModel.
183- assert config_custom .dem == stim .DetectorErrorModel ()
184-
185- # Assert that the string representation reflects the custom values.
186- assert (
187- str (config_custom )
188- == "TesseractConfig(dem=DetectorErrorModel_Object, det_beam=15, no_revisit_dets=0, at_most_two_errors_per_detector=0, verbose=1, merge_errors=1, pqlimit=18446744073709551615, det_orders=[], det_penalty=0, create_visualization=0)"
189- )
182+ config = tesseract_decoder .tesseract .TesseractConfig (det_beam = 15 , verbose = True )
183+
184+ assert config .dem == stim .DetectorErrorModel ()
185+ assert config .det_beam == 15
186+ assert config .no_revisit_dets is True
187+ assert config .at_most_two_errors_per_detector is False
188+ assert config .verbose is True
189+ assert config .merge_errors is True
190+ assert config .pqlimit == 200000
191+ assert config .det_penalty == 0.0
192+ assert config .create_visualization is False
190193
191194
192195def test_create_tesseract_decoder ():
0 commit comments