From 1658ac329a02d8ef5e3ea503068a63b04a265518 Mon Sep 17 00:00:00 2001 From: keitaroyam Date: Fri, 24 May 2024 17:21:34 +0900 Subject: [PATCH] python: SeqId made hashable --- python/meta.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/meta.cpp b/python/meta.cpp index 3e325827..6113f479 100644 --- a/python/meta.cpp +++ b/python/meta.cpp @@ -50,7 +50,10 @@ void add_meta(py::module& m) { throw std::runtime_error("invalid tuple size"); return SeqId(t[0].cast(), t[1].cast()); } - )); + )) + .def("__hash__", [](const SeqId& self) { + return py::hash(py::make_tuple(self.num, self.icode)); + }); py::class_(m, "ResidueId") .def(py::init<>())