[SyneRBI/SIRF] `Handle` everything (PR #1388)

0 views
Skip to first unread message

Casper da Costa-Luis

unread,
Mar 25, 2026, 2:29:12 PM (13 days ago) Mar 25
to SyneRBI/SIRF, Subscribed

add Utilities.Handle wrapper (fixes #1384)

  • update SIRF
  • update STIR
  • update Reg
  • update Gadgetron
  • fix tests
  • update docs & changelog

You can view, comment on, or merge this pull request online at:

  https://github.com/SyneRBI/SIRF/pull/1388

Commit Summary

File Changes

(7 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388@github.com>

Kris Thielemans

unread,
Mar 26, 2026, 6:32:49 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.


In src/common/SIRF.py:

> @@ -210,10 +206,8 @@ def same_object(self):
         return DataContainer()
 
     def clone(self):
-        assert self.handle is not None

In case handle is None, we'd now get a cryptic error without the assert?


In src/common/Utilities.py:

> +    def __getattr__(self, name):
+        assert self.valid
+        match name.split('_', 1)[0]:
+            case 'cSIRF':
+                func = getattr(pysirf, name)
+            case 'cReg':
+                import sirf.pyreg as pyreg
+                func = getattr(pyreg, name)
+            case 'cGT':
+                import sirf.pygadgetron as pygadgetron
+                func = getattr(pygadgetron, name)
+            case 'cSTIR':
+                import sirf.pystir as pystir
+                func = getattr(pystir, name)
+            case _:
+                raise AttributeError("namespace of %s" % name)

probably a bit cryptic error


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/review/4012863770@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 7:40:41 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Subscribed

@casperdcl commented on this pull request.


In src/common/SIRF.py:

> @@ -210,10 +206,8 @@ def same_object(self):
         return DataContainer()
 
     def clone(self):
-        assert self.handle is not None

Before, we'd just get AssertionError (no message).

Now, we'd get AttributeError: 'NoneType' object has no attribute 'cSIRF_clone' which to me seems an improvement.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/review/4013411952@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 7:47:35 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Push

@casperdcl pushed 6 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/before/a34c47267c23171758c4aaad44372ba842e13acc/after/540566201928854d035ba4ed3927cb59fed29405@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 8:01:13 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Push

@casperdcl pushed 3 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/before/540566201928854d035ba4ed3927cb59fed29405/after/87e63dfe50b85af2db78094a1525a3e4ce96ae5b@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 8:01:56 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Subscribed

@casperdcl commented on this pull request.


In src/common/Utilities.py:

> +
+    def __str__(self):
+        return pyiutil.charDataFromHandle(self._handle)
+
+    def __abs__(self):
+        return pyiutil.size_tDataFromHandle(self._handle)
+
+    def __complex__(self, double=False):
+        if double:
+            return pyiutil.doubleReDataFromHandle(self._handle) + 1.j * pyiutil.doubleImDataFromHandle(self._handle)
+        return pyiutil.floatReDataFromHandle(self._handle) + 1.j * pyiutil.floatImDataFromHandle(self._handle)
+
+    def __del__(self):
+        if self._handle is not None:
+            pyiutil.deleteDataHandle(self._handle)
+        self._handle = None  # TODO: is this required?

ideally deleteDataHandle should transform the object to None, but I'm unsure


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/review/4013544147@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 11:17:51 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Push

@casperdcl pushed 5 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/before/87e63dfe50b85af2db78094a1525a3e4ce96ae5b/after/a8bf5e27e9f15d14b187d2dffb35e7718b48ee4e@github.com>

Casper da Costa-Luis

unread,
Mar 26, 2026, 12:28:51 PM (12 days ago) Mar 26
to SyneRBI/SIRF, Subscribed
casperdcl left a comment (SyneRBI/SIRF#1388)

All tests passing; codacy can be ignored. 1k fewer lines :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/c4136409260@github.com>

Kris Thielemans

unread,
Mar 27, 2026, 12:58:12 PM (11 days ago) Mar 27
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.


In src/common/Utilities.py:

> +
+    def __str__(self):
+        return pyiutil.charDataFromHandle(self._handle)
+
+    def __abs__(self):
+        return pyiutil.size_tDataFromHandle(self._handle)
+
+    def __complex__(self, double=False):
+        if double:
+            return pyiutil.doubleReDataFromHandle(self._handle) + 1.j * pyiutil.doubleImDataFromHandle(self._handle)
+        return pyiutil.floatReDataFromHandle(self._handle) + 1.j * pyiutil.floatImDataFromHandle(self._handle)
+
+    def __del__(self):
+        if self._handle is not None:
+            pyiutil.deleteDataHandle(self._handle)
+        self._handle = None  # TODO: is this required?

better safe than sorry


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/review/4022470475@github.com>

Kris Thielemans

unread,
Mar 27, 2026, 1:00:09 PM (11 days ago) Mar 27
to SyneRBI/SIRF, Subscribed

@KrisThielemans approved this pull request.

fine for me. I didn't check the detail of course.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/review/4022482192@github.com>

Casper da Costa-Luis

unread,
Mar 27, 2026, 1:11:47 PM (11 days ago) Mar 27
to SyneRBI/SIRF, Subscribed

Merged #1388 into master.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1388/issue_event/23979474570@github.com>

Reply all
Reply to author
Forward
0 new messages