diff --git a/CHANGES.md b/CHANGES.md index 80915e22c..640ebd63d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,10 +22,11 @@ - `ImageData` and `AcquisitionDataInMemory` have `supports_array_view==True` * SIRF/Gadgetron - - `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). + - `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. * SIRF/Registration - Nifty images have `supports_array_view==True` + - 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__`. * CI and testing - made tests return value handling compatible with a future version of pytest. diff --git a/examples/Python/MR/data_views.py b/examples/Python/MR/data_views.py index cf3a4df89..3c43214d7 100644 --- a/examples/Python/MR/data_views.py +++ b/examples/Python/MR/data_views.py @@ -11,6 +11,13 @@ {licence} """ + +import numpy +numpy_major = int(numpy.__version__[0]) +if numpy_major < 2: + print('Using data views requires numpy version major not less than 2, exiting.') + exit() + from sirf.SIRF import norm, dot, copyto from sirf.Gadgetron import AcquisitionData, \ AcquisitionDataView, ImageDataView, FullySampledReconstructor diff --git a/examples/Python/MR/mr_timings.py b/examples/Python/MR/mr_timings.py index db1f99fb0..f8119465f 100755 --- a/examples/Python/MR/mr_timings.py +++ b/examples/Python/MR/mr_timings.py @@ -19,6 +19,11 @@ """ import numpy +numpy_major = int(numpy.__version__[0]) +if numpy_major < 2: + print('Using data views requires numpy version major not less than 2, exiting.') + exit() + import timeit import importlib