Skip to content

Commit 70f6fce

Browse files
Clarify MR data views in the case of numpy version 1.* (#1366)
Clarify in documentation and test cases that numpy 2 is required for some functionality.
1 parent 0ba22c9 commit 70f6fce

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
- `ImageData` and `AcquisitionDataInMemory` have `supports_array_view==True`
2323

2424
* SIRF/Gadgetron
25-
- `ImageDataView` and `AcquisitionDataView` classes implemented that encapsulate arrays of NumPy views of `ISMRMRD_ImageData` and `ISMRMRD_AcquisitionData` objects respectively, significantly accelerating the algebraic operations (up to a factor of about 10 for images).
25+
- `ImageDataView` and `AcquisitionDataView` classes implemented that encapsulate arrays of NumPy views of `ISMRMRD_ImageData` and `ISMRMRD_AcquisitionData` objects respectively, significantly accelerating the algebraic operations (up to a factor of about 10 for images). As these classes require numpy version major being not less than 2, tests that use them are skipped if this requirement is not met.
2626

2727
* SIRF/Registration
2828
- Nifty images have `supports_array_view==True`
29+
- PET/Registration `ImageData` and PET `AcquisitionData` have `.asarray(copy=False)` (NumPy-like behaviour: default zero-copy if contiguous, fallback to deepcopy otherwise) via `__array_interface__`.
2930

3031
* CI and testing
3132
- made tests return value handling compatible with a future version of pytest.

examples/Python/MR/data_views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
1212
{licence}
1313
"""
14+
15+
import numpy
16+
numpy_major = int(numpy.__version__[0])
17+
if numpy_major < 2:
18+
print('Using data views requires numpy version major not less than 2, exiting.')
19+
exit()
20+
1421
from sirf.SIRF import norm, dot, copyto
1522
from sirf.Gadgetron import AcquisitionData, \
1623
AcquisitionDataView, ImageDataView, FullySampledReconstructor

examples/Python/MR/mr_timings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"""
2020

2121
import numpy
22+
numpy_major = int(numpy.__version__[0])
23+
if numpy_major < 2:
24+
print('Using data views requires numpy version major not less than 2, exiting.')
25+
exit()
26+
2227
import timeit
2328
import importlib
2429

0 commit comments

Comments
 (0)