diff --git a/.clang-format b/.clang-format index 92eae3968..923c3a234 100644 --- a/.clang-format +++ b/.clang-format @@ -11,12 +11,13 @@ AllowShortLoopsOnASingleLine: false AllowShortLambdasOnASingleLine: None BinPackArguments: false BinPackParameters: false - +PointerAlignment: Right +ReferenceAlignment: Right IncludeCategories: - - Regex: '^<.*>$' - Priority: 1 - - Regex: '^"gtest/.*"$' - Priority: 2 - - Regex: '^".*"$' - Priority: 3 + - Regex: "^<.*>$" + Priority: 1 + - Regex: '^"gtest/.*"$' + Priority: 2 + - Regex: '^".*"$' + Priority: 3 ... diff --git a/src/pymatching/sparse_blossom/driver/user_graph.pybind.cc b/src/pymatching/sparse_blossom/driver/user_graph.pybind.cc index 7b227e5cc..0fb989329 100644 --- a/src/pymatching/sparse_blossom/driver/user_graph.pybind.cc +++ b/src/pymatching/sparse_blossom/driver/user_graph.pybind.cc @@ -612,4 +612,64 @@ void pm_pybind::pybind_user_graph_methods(py::module &m, py::class_(), t[1].cast()); + g.boundary_nodes = t[3].cast>(); + g.loaded_from_dem_without_correlations = t[4].cast(); + + for (const auto &edge_obj : t[2].cast()) { + auto et = edge_obj.cast(); + pm::UserEdge edge; + edge.node1 = et[0].cast(); + edge.node2 = et[1].cast(); + edge.observable_indices = et[2].cast>(); + edge.weight = et[3].cast(); + edge.error_probability = et[4].cast(); + + for (const auto &iw_obj : et[5].cast()) { + auto iw_tuple = iw_obj.cast(); + edge.implied_weights_for_other_edges.emplace_back( + iw_tuple[0].cast(), iw_tuple[1].cast(), iw_tuple[2].cast()); + } + + g.edges.push_back(edge); + auto edge_it = std::prev(g.edges.end()); + + g.nodes[edge.node1].neighbors.push_back({edge_it, 1}); + g.nodes[edge.node2].neighbors.push_back({edge_it, 0}); + } + + for (size_t i : g.boundary_nodes) + if (i < g.nodes.size()) + g.nodes[i].is_boundary = true; + + return g; + })); }