From 57e79d908e10f2c675ec38f60b9d6159feff5cb1 Mon Sep 17 00:00:00 2001 From: Alice Date: Fri, 14 Nov 2025 11:12:34 +0100 Subject: [PATCH] API also allows single sequence for single ROI --- python/slsdet/detector.py | 12 +++++++++++- python/src/detector.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index e49ddd06a..59b3b2168 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -24,6 +24,7 @@ import datetime as dt from functools import wraps from collections import namedtuple +from collections.abc import Sequence import socket import numpy as np @@ -321,7 +322,16 @@ class Detector(CppDetectorApi): Each ROI should be represented as a tuple of (x_start, y_start, x_end, y_end). \n Example: [(0, 100, 50, 100)] \n """ - self.setRxROI(rois) + # TODO: maybe better to accept py::object in setRxROI and handle there? + if not isinstance(rois, Sequence): + raise TypeError( + "setRxROI failed: expected a tuple/list of ints x_min, x_max, y_min, y_max " + "or a sequence of such." + ) + if(not isinstance(rois[0], Sequence)): + self.setRxROI([rois]) + else: + self.setRxROI(rois) @property diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 4b41c636a..be166480f 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -938,6 +938,7 @@ void init_det(py::module &m) { (void(Detector::*)(const std::vector &)) & Detector::setRxROI, py::arg()); + CppDetectorApi.def("clearRxROI", (void(Detector::*)()) & Detector::clearRxROI); CppDetectorApi.def(