More uniform binding of Numpy arrays (#381)
Build on RHEL9 / build (push) Successful in 2m54s
Build on RHEL8 / build (push) Successful in 3m31s
Run tests using data on local RHEL8 / build (push) Failing after 4m28s
Build on local RHEL8 / build (push) Successful in 3m6s

- Introduce a standard way to bind numpy arrays: py::array_t<T> and
.noconvert() on the argument
- Take py::array_t by value since it's just a small wrapper
- Update bindings
This commit is contained in:
Erik Fröjdh authored and GitHub committed 2026-09-25 14:40:33 +02:00
1 parent 8579a140f7
commit 941325ea15
26 files changed
+597 -280

No files matched your search

+3 -14
View File
@@ -85,11 +85,7 @@ void define_pedestal_bindings(py::module &m, const std::string &name) {
// TODO! add push for other data types
.def(
"push",
[](Pedestal<SUM_TYPE> &pedestal,
py::array_t<uint16_t, py::array::c_style> &f) {
if (f.ndim() != 2) {
throw py::value_error("Frame must be 2-dimensional");
}
[](Pedestal<SUM_TYPE> &pedestal, py::array_t<uint16_t> f) {
auto v = make_view_2d(f);
pedestal.push(v);
},
@@ -99,15 +95,8 @@ void define_pedestal_bindings(py::module &m, const std::string &name) {
"n_samples values per pixel, new values have weight 1 / n_samples.")
.def(
"push_with_threshold",
[](Pedestal<SUM_TYPE> &pedestal,
py::array_t<uint16_t, py::array::c_style> &f,
py::array_t<SUM_TYPE, py::array::c_style> &threshold) {
if (f.ndim() != 2) {
throw py::value_error("Frame must be 2-dimensional");
}
if (threshold.ndim() != 2) {
throw py::value_error("Threshold must be 2-dimensional");
}
[](Pedestal<SUM_TYPE> &pedestal, py::array_t<uint16_t> f,
py::array_t<SUM_TYPE> threshold) {
auto frame_view = make_view_2d(f);
auto threshold_view = make_view_2d(threshold);
pedestal.push_with_threshold(frame_view, threshold_view);