Skip to content

Commit 80ebbc8

Browse files
committed
Adds pybind11/stl.h header to serialize vector objects.
1 parent c323abc commit 80ebbc8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pybnesian/util/pickle.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
#define PYBNESIAN_UTIL_PICKLE_HPP
33

44
#include <pybind11/pybind11.h>
5+
#include <pybind11/stl.h>
56

67
namespace py = pybind11;
78

89
namespace util {
910

1011
template <typename OBJ>
11-
void save_object(const OBJ& factor, std::string name) {
12+
void save_object(const OBJ& obj, std::string name) {
1213
auto open = py::module_::import("io").attr("open");
1314

1415
if (name.size() < 7 || name.substr(name.size() - 7) != ".pickle") name += ".pickle";
1516

1617
auto file = open(name, "wb");
17-
py::module_::import("pickle").attr("dump")(py::cast(&factor), file, 2);
18+
py::module_::import("pickle").attr("dump")(py::cast(&obj), file, 2);
1819
file.attr("close")();
1920
}
2021

0 commit comments

Comments
 (0)