Contiguity checks for STIR image data
- fixes #1316
- ~test demo script
asarray.pyprovided~ - ~requires STIR branch
contiguous_Arrays(https://github.com/UCL/STIR/pull/1592)~
Checklist
- [x] I have performed a self-review of my code
- [ ] I have added docstrings/doxygen in line with the guidance in the developer guide
- [ ] I have implemented unit tests that cover any new or modified functionality
- [x] The code builds and runs on my machine
- [ ] CHANGES.md has been updated with any functionality change
Latest performance comparison (with this PR #1317 + https://github.com/UCL/STIR/pull/1592 + #1314) - the last column shows timings we can get with asarray.
test sirf as_array + numpy + fill = total asarray
x * 2 7.28e-02 5.21e-01 + 5.53e-03 + 5.18e-01 = 1.04e+00 8.37e-03
x + 2 7.87e-02 5.26e-01 + 5.76e-03 + 4.99e-01 = 1.03e+00 7.77e-03
x + y 9.43e-02 1.08e+00 + 6.31e-03 + 5.02e-01 = 1.59e+00 1.16e-02
x * y 1.11e-01 1.06e+00 + 6.85e-03 + 5.07e-01 = 1.57e+00 9.82e-03
x / y 1.28e-01 1.01e+00 + 7.28e-03 + 5.13e-01 = 1.53e+00 8.14e-03
~10-15 times faster? Great!
I just rebased this PR to be off master so it can be self-contained and easy to merge :)
I'll rebase #1314 afterwards.
Might need this on AquisitionData too @KrisThielemans?
I think in the need we need the array_interface stuff (and hence this property I guess) in DataContainer, defaulting to false. Overloaded in STIR.ImageData as currently done, and overloaded in STIR.AcquisitionDataInMemory to `true.
TBH, it is a somewhat strange property to have on DataContainer, as we'd be using it essentially to say "yup, you can have array interface access, and it happens to be that the underlying is contiguous, such that we can support it." Naming of the property is therefore probably a bit wrong.
What about renaming contiguous to supports_array_view or so?
makes sense to me... /CC @evgueni-ovtchinnikov ☝️
Potentially @evgueni-ovtchinnikov implemented supports_array_view in the branch data-algebra-opt (#1318)
https://github.com/SyneRBI/SIRF/blob/fce31b7311df6ef3874159c22c49034fe73089b7/src/common/include/sirf/common/DataContainer.h#L65-L68