-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathedge_vertex.cpp
More file actions
43 lines (39 loc) · 1.65 KB
/
edge_vertex.cpp
File metadata and controls
43 lines (39 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <common.hpp>
#include <ipc/candidates/edge_vertex.hpp>
namespace py = pybind11;
using namespace ipc;
void define_edge_vertex_candidate(py::module_& m)
{
py::class_<EdgeVertexCandidate, CollisionStencil>(m, "EdgeVertexCandidate")
.def(py::init<long, long>(), py::arg("edge_id"), py::arg("vertex_id"))
.def(
py::init([](std::tuple<long, long> edge_and_vertex_id) {
return std::make_unique<EdgeVertexCandidate>(
std::get<0>(edge_and_vertex_id),
std::get<1>(edge_and_vertex_id));
}),
py::arg("edge_and_vertex_id"))
.def("known_dtype", &EdgeVertexCandidate::known_dtype)
.def(
"__str__",
[](const EdgeVertexCandidate& ev) {
return fmt::format("[{:d}, {:d}]", ev.edge_id, ev.vertex_id);
})
.def(
"__repr__",
[](const EdgeVertexCandidate& ev) {
return fmt::format(
"EdgeVertexCandidate({:d}, {:d})", ev.edge_id,
ev.vertex_id);
})
.def("__eq__", &EdgeVertexCandidate::operator==, py::arg("other"))
.def("__ne__", &EdgeVertexCandidate::operator!=, py::arg("other"))
.def(
"__lt__", &EdgeVertexCandidate::operator<,
"Compare EdgeVertexCandidates for sorting.", py::arg("other"))
.def_readwrite(
"edge_id", &EdgeVertexCandidate::edge_id, "ID of the edge")
.def_readwrite(
"vertex_id", &EdgeVertexCandidate::vertex_id, "ID of the vertex");
py::implicitly_convertible<std::tuple<long, long>, EdgeVertexCandidate>();
}