|
21 | 21 | #include <pybind11/pybind11.h> |
22 | 22 | #include <pybind11/stl.h> |
23 | 23 |
|
24 | | -#include <sstream> |
25 | | - |
26 | 24 | #include "stim_utils.pybind.h" |
27 | 25 | #include "tesseract.h" |
28 | 26 |
|
@@ -249,15 +247,10 @@ void add_tesseract_module(py::module& root) { |
249 | 247 | "decode_to_errors", |
250 | 248 | [](TesseractDecoder& self, const py::array_t<bool>& syndrome) { |
251 | 249 | if ((size_t)syndrome.size() != self.num_detectors) { |
252 | | - std::ostringstream msg; |
253 | | - msg << "Syndrome array size (" << syndrome.size() |
254 | | - << ") does not match the number of detectors in the decoder (" |
255 | | - << self.num_detectors << ")."; |
256 | | - std::string msg = "Syndrome array size (" + |
257 | | - std |
258 | | - : to_string(syndrome.size()) + |
259 | | - ") does not match the number of detectors in the decoder (" + |
260 | | - std::to_string(self.num_detectors) + ")." throw std::invalid_argument(msg); |
| 250 | + std::string msg = "Syndrome array size (" + std::to_string(syndrome.size()) + |
| 251 | + ") does not match the number of detectors in the decoder (" + |
| 252 | + std::to_string(self.num_detectors) + ")."; |
| 253 | + throw std::invalid_argument(msg); |
261 | 254 | } |
262 | 255 |
|
263 | 256 | std::vector<uint64_t> detections; |
@@ -291,11 +284,10 @@ void add_tesseract_module(py::module& root) { |
291 | 284 | [](TesseractDecoder& self, const py::array_t<bool>& syndrome, size_t det_order, |
292 | 285 | size_t det_beam) { |
293 | 286 | if ((size_t)syndrome.size() != self.num_detectors) { |
294 | | - std::ostringstream msg; |
295 | | - msg << "Syndrome array size (" << syndrome.size() |
296 | | - << ") does not match the number of detectors in the decoder (" |
297 | | - << self.num_detectors << ")."; |
298 | | - throw std::invalid_argument(msg.str()); |
| 287 | + std::string msg = "Syndrome array size (" + std::to_string(syndrome.size()) + |
| 288 | + ") does not match the number of detectors in the decoder (" + |
| 289 | + std::to_string(self.num_detectors) + ")."; |
| 290 | + throw std::invalid_argument(msg); |
299 | 291 | } |
300 | 292 |
|
301 | 293 | std::vector<uint64_t> detections; |
@@ -403,11 +395,10 @@ void add_tesseract_module(py::module& root) { |
403 | 395 | "decode", |
404 | 396 | [](TesseractDecoder& self, const py::array_t<bool>& syndrome) { |
405 | 397 | if ((size_t)syndrome.size() != self.num_detectors) { |
406 | | - std::ostringstream msg; |
407 | | - msg << "Syndrome array size (" << syndrome.size() |
408 | | - << ") does not match the number of detectors in the decoder (" |
409 | | - << self.num_detectors << ")."; |
410 | | - throw std::invalid_argument(msg.str()); |
| 398 | + std::string msg = "Syndrome array size (" + std::to_string(syndrome.size()) + |
| 399 | + ") does not match the number of detectors in the decoder (" + |
| 400 | + std::to_string(self.num_detectors) + ")."; |
| 401 | + throw std::invalid_argument(msg); |
411 | 402 | } |
412 | 403 |
|
413 | 404 | std::vector<uint64_t> detections; |
@@ -461,11 +452,11 @@ void add_tesseract_module(py::module& root) { |
461 | 452 | size_t num_detectors = syndromes_unchecked.shape(1); |
462 | 453 |
|
463 | 454 | if (num_detectors != self.num_detectors) { |
464 | | - std::ostringstream msg; |
465 | | - msg << "The number of detectors in the input array (" << num_detectors |
466 | | - << ") does not match the number of detectors in the decoder (" |
467 | | - << self.num_detectors << ")."; |
468 | | - throw std::invalid_argument(msg.str()); |
| 455 | + std::string msg = "The number of detectors in the input array (" + |
| 456 | + std::to_string(num_detectors) + |
| 457 | + ") does not match the number of detectors in the decoder (" + |
| 458 | + std::to_string(self.num_detectors) + ")."; |
| 459 | + throw std::invalid_argument(msg); |
469 | 460 | } |
470 | 461 |
|
471 | 462 | // Allocate the result array. |
|
0 commit comments