micro-manager/pymmcore

getMultiROI appears broken in pymmcore swig

tlambert03 opened this issue · 2 comments

the core void CMMCore::getMultiROI method populates 4 std::vector<unsigned>& with ROI info. The swig conversion doesn't appear to be working?

In [4]: core.getMultiROI([],[],[],[])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 core.getMultiROI([],[],[],[])

TypeError: in method 'CMMCore_getMultiROI', argument 2 of type 'std::vector< unsigned int,std::allocator< unsigned int > > &'

Yep. Vector of unsigned is not mentioned in pymmcore_swig.i, so this probably never worked.

If I add the one-liner

     %template(LongVector)   vector<long>;
+    %template(UnsignedVector)   vector<unsigned>;
     %template(DoubleVector) vector<double>;

Then the following works.

xs = pymmcore.UnsignedVector()
ys = pymmcore.UnsignedVector()
ws = pymmcore.UnsignedVector()
hs = pymmcore.UnsignedVector()
core = pymmcore.CMMCore()
core.getMultiROI(xs, ys, ws, hs)

UnsignedVector converts to list with list(xs), etc.

Do you think this would be a good enough fix to wrap in pymmcore-plus?

sure, can do