@@ -289,5 +289,31 @@ void pybind_sinter_compat(py::module& root) {
289289 .def (py::self == py::self,
290290 R"pbdoc( Checks if two TesseractSinterDecoder instances are equal.)pbdoc" )
291291 .def (py::self != py::self,
292- R"pbdoc( Checks if two TesseractSinterDecoder instances are not equal.)pbdoc" );
292+ R"pbdoc( Checks if two TesseractSinterDecoder instances are not equal.)pbdoc" )
293+ .def (py::pickle (
294+ [](const TesseractSinterDecoder& self) -> py::tuple { // __getstate__
295+ return py::make_tuple (
296+ std::string (self.config .dem .str ()), self.config .det_beam , self.config .beam_climbing ,
297+ self.config .no_revisit_dets , self.config .at_most_two_errors_per_detector ,
298+ self.config .verbose , self.config .merge_errors , self.config .pqlimit ,
299+ self.config .det_orders , self.config .det_penalty , self.config .create_visualization );
300+ },
301+ [](py::tuple t) { // __setstate__
302+ if (t.size () != 11 ) {
303+ throw std::runtime_error (" Invalid state for TesseractSinterDecoder!" );
304+ }
305+ TesseractConfig config;
306+ config.dem = stim::DetectorErrorModel (t[0 ].cast <std::string>());
307+ config.det_beam = t[1 ].cast <int >();
308+ config.beam_climbing = t[2 ].cast <bool >();
309+ config.no_revisit_dets = t[3 ].cast <bool >();
310+ config.at_most_two_errors_per_detector = t[4 ].cast <bool >();
311+ config.verbose = t[5 ].cast <bool >();
312+ config.merge_errors = t[6 ].cast <bool >();
313+ config.pqlimit = t[7 ].cast <size_t >();
314+ config.det_orders = t[8 ].cast <std::vector<std::vector<size_t >>>();
315+ config.det_penalty = t[9 ].cast <double >();
316+ config.create_visualization = t[10 ].cast <bool >();
317+ return TesseractSinterDecoder (config);
318+ }));
293319}
0 commit comments