From ebf06e09e17c9e47fc13d1ea01c805928b88a9be Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 1 Jul 2026 14:38:10 +0200 Subject: [PATCH] forgot to add jungfraucalibration --- python/src/utils/bind_SparseMask.hpp | 16 ++++++++++++++ python/src/utils/bind_Vector.hpp | 32 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 python/src/utils/bind_SparseMask.hpp create mode 100644 python/src/utils/bind_Vector.hpp diff --git a/python/src/utils/bind_SparseMask.hpp b/python/src/utils/bind_SparseMask.hpp new file mode 100644 index 0000000..a041871 --- /dev/null +++ b/python/src/utils/bind_SparseMask.hpp @@ -0,0 +1,16 @@ +#include "aare/utils/SparseMask.hpp" +#include + +namespace py = pybind11; + +using namespace aare; + +void define_sparse_mask_bindings(py::module &m) { + + py::class_(m, "SparseMask") + .def(py::init(), + py::arg("storage_format"), py::arg("rows"), py::arg("cols")) + .def("insert", &SparseMask::insert, py::arg("row"), py::arg("col")) + .def("is_masked", &SparseMask::is_masked, py::arg("row"), + py::arg("col")); +} diff --git a/python/src/utils/bind_Vector.hpp b/python/src/utils/bind_Vector.hpp new file mode 100644 index 0000000..49b1829 --- /dev/null +++ b/python/src/utils/bind_Vector.hpp @@ -0,0 +1,32 @@ +#pragma once +#include +// #include +// #include +#include + +namespace py = pybind11; + +// TODO add index, itemize +template +void define_Vector(py::module &m, const std::string &type_str, + const std::string &format_string) { + auto class_name = "Vector_" + type_str; + + py::class_>(m, class_name.c_str(), py::buffer_protocol()) + + .def(py::init()) + + .def_buffer([&format_string]( + std::vector &self) -> py::buffer_info { + return py::buffer_info( + self.data(), static_cast(sizeof(Type)), + format_string, static_cast(1), + std::vector{static_cast(self.size())}, + std::vector{ + static_cast(sizeof(Type))}); + }); +} + +void define_Struct(py::module &m, ) + + // fmt::format("T{{{}:sum:i:index}}",py::format_descriptor::format()) \ No newline at end of file