add Utilities.Handle wrapper (fixes #1384)
https://github.com/SyneRBI/SIRF/pull/1388
(7 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@KrisThielemans commented on this pull request.
> @@ -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?
> + 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.![]()
@casperdcl commented on this pull request.
> @@ -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.![]()
@casperdcl pushed 6 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@casperdcl pushed 3 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@casperdcl commented on this pull request.
> + + 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.![]()
@casperdcl pushed 5 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
@KrisThielemans commented on this pull request.
> + + 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.![]()
@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.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()