2727
2828namespace py = pybind11;
2929
30+ namespace tesseract_decoder {
3031namespace {
32+
3133// Helper function to compile the decoder.
3234std::unique_ptr<SimplexDecoder> _compile_simplex_decoder_helper (const SimplexConfig& self) {
3335 return std::make_unique<SimplexDecoder>(self);
@@ -41,19 +43,27 @@ SimplexConfig simplex_config_maker(py::object dem, bool parallelize = false,
4143 {input_dem, parallelize, window_length, window_slide_length, verbose, merge_errors});
4244}
4345
44- }; // namespace
46+ } // namespace
4547
4648void add_simplex_module (py::module & root) {
4749 auto m =
4850 root.def_submodule (" simplex" , " Module containing the SimplexDecoder and related methods" );
4951
50- py::class_<SimplexConfig>(m, " SimplexConfig" , R"pbdoc(
52+ auto py_simplex_config = py::class_<SimplexConfig>(m, " SimplexConfig" , R"pbdoc(
5153 Configuration object for the `SimplexDecoder`.
5254
5355 This class holds all the parameters needed to initialize and configure a
5456 Simplex decoder instance, including the detector error model and
5557 decoding options.
56- )pbdoc" )
58+ )pbdoc" );
59+ auto py_simplex_decoder = py::class_<SimplexDecoder>(m, " SimplexDecoder" , R"pbdoc(
60+ A class that implements the Simplex decoding algorithm.
61+
62+ It can decode syndromes from a `stim.DetectorErrorModel` to predict
63+ which observables have been flipped.
64+ )pbdoc" );
65+
66+ py_simplex_config
5767 .def (py::init (&simplex_config_maker), py::arg (" dem" ), py::arg (" parallelize" ) = false ,
5868 py::arg (" window_length" ) = 0 , py::arg (" window_slide_length" ) = 0 ,
5969 py::arg (" verbose" ) = false , py::arg (" merge_errors" ) = true , R"pbdoc(
@@ -101,12 +111,7 @@ void add_simplex_module(py::module& root) {
101111 settings.
102112 )pbdoc" );
103113
104- py::class_<SimplexDecoder>(m, " SimplexDecoder" , R"pbdoc(
105- A class that implements the Simplex decoding algorithm.
106-
107- It can decode syndromes from a `stim.DetectorErrorModel` to predict
108- which observables have been flipped.
109- )pbdoc" )
114+ py_simplex_decoder
110115 .def (py::init<SimplexConfig>(), py::arg (" config" ), R"pbdoc(
111116 The constructor for the `SimplexDecoder` class.
112117
@@ -351,4 +356,7 @@ void add_simplex_module(py::module& root) {
351356 (num_shots, num_observables).
352357 )pbdoc" );
353358}
359+
360+ } // namespace tesseract_decoder
361+
354362#endif
0 commit comments