From f757ae3a98b49b34bbf08ab53e5724d17000e7c9 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 9 Jan 2018 14:37:20 +0100 Subject: Add astra.test/astra_test function --- README.md | 11 ++++------- README.txt | 11 ++++------- matlab/tools/astra_test.m | 19 +++++++++++++++++++ matlab/tools/astra_test_CUDA.m | 3 +-- matlab/tools/astra_test_noCUDA.m | 3 +-- python/astra/__init__.py | 4 ++-- python/astra/tests.py | 10 ++++++++++ 7 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 matlab/tools/astra_test.m diff --git a/README.md b/README.md index f36bdea..c5c38b7 100644 --- a/README.md +++ b/README.md @@ -126,20 +126,17 @@ For python 2.7/3.5: Run build_python27.bat or build_python35.bat. Astra will be ## Testing your installation To perform a (very) basic test of your ASTRA installation in Python, you can -run the following Python commands. You can choose to skip the test of the GPU -functionality for systems without a NVIDIA GPU. +run the following Python command. ``` import astra -astra.test_noCUDA() # To skip GPU tests -astra.test_CUDA() # To also perform GPU tests +astra.test() ``` -To test your ASTRA installation in Matlab, the equivalent commands are: +To test your ASTRA installation in Matlab, the equivalent command is: ``` -astra_test_noCUDA % To skip GPU tests -astra_test_CUDA % To also perform GPU tests +astra_test ``` ## References diff --git a/README.txt b/README.txt index 69b3b3b..5ff8a56 100644 --- a/README.txt +++ b/README.txt @@ -155,18 +155,15 @@ Testing your installation: --------------------------- To perform a (very) basic test of your ASTRA installation in Python, you can -run the following Python commands. You can choose to skip the test of the GPU -functionality for systems without a NVIDIA GPU. +run the following Python command. import astra -astra.test_noCUDA() # To skip GPU tests -astra.test_CUDA() # To also perform GPU tests +astra.test() -To test your ASTRA installation in Matlab, the equivalent commands are: +To test your ASTRA installation in Matlab, the equivalent command is: -astra_test_noCUDA % To skip GPU tests -astra_test_CUDA % To also perform GPU tests +astra_test References: diff --git a/matlab/tools/astra_test.m b/matlab/tools/astra_test.m new file mode 100644 index 0000000..907443c --- /dev/null +++ b/matlab/tools/astra_test.m @@ -0,0 +1,19 @@ +%-------------------------------------------------------------------------- +% Perform a basic test of ASTRA functionality. +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- +% This file is part of the ASTRA Toolbox +% +% Copyright: 2010-2018, iMinds-Vision Lab, University of Antwerp +% 2014-2018, CWI, Amsterdam +% License: Open Source under GPLv3 +% Contact: astra@uantwerpen.be +% Website: http://www.astra-toolbox.com/ +%-------------------------------------------------------------------------- + +if astra_mex('use_cuda') + astra_test_CUDA; +else + fprintf('No GPU support available') + astra_test_noCUDA; +end diff --git a/matlab/tools/astra_test_CUDA.m b/matlab/tools/astra_test_CUDA.m index 4171f20..28de3f1 100644 --- a/matlab/tools/astra_test_CUDA.m +++ b/matlab/tools/astra_test_CUDA.m @@ -1,6 +1,5 @@ %-------------------------------------------------------------------------- -% Clears and frees memory of all objects (data, projectors, algorithms) -% currently in the astra-library. +% Perform a basic test of ASTRA CUDA functionality. %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- % This file is part of the ASTRA Toolbox diff --git a/matlab/tools/astra_test_noCUDA.m b/matlab/tools/astra_test_noCUDA.m index 6437661..42a6931 100644 --- a/matlab/tools/astra_test_noCUDA.m +++ b/matlab/tools/astra_test_noCUDA.m @@ -1,6 +1,5 @@ %-------------------------------------------------------------------------- -% Clears and frees memory of all objects (data, projectors, algorithms) -% currently in the astra-library. +% Perform a basic test of ASTRA CPU functionality. %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- % This file is part of the ASTRA Toolbox diff --git a/python/astra/__init__.py b/python/astra/__init__.py index 4675229..e813194 100644 --- a/python/astra/__init__.py +++ b/python/astra/__init__.py @@ -27,7 +27,7 @@ from . import matlab as m from .creators import astra_dict,create_vol_geom, create_proj_geom, create_backprojection, create_sino, create_reconstruction, create_projector,create_sino3d_gpu, create_backprojection3d_gpu from .functions import data_op, add_noise_to_sino, clear, move_vol_geom from .extrautils import clipCircle -from .astra import set_gpu_index, get_gpu_info +from .astra import set_gpu_index, get_gpu_info, use_cuda from . import data2d from . import astra from . import data3d @@ -39,7 +39,7 @@ from . import plugin from . import plugins from . import log from .optomo import OpTomo -from .tests import test_noCUDA, test_CUDA +from .tests import test, test_noCUDA, test_CUDA __version__ = '1.9.0dev' diff --git a/python/astra/tests.py b/python/astra/tests.py index 32afd36..f7c2c04 100644 --- a/python/astra/tests.py +++ b/python/astra/tests.py @@ -95,3 +95,13 @@ def test_CUDA(): ok3 = _basic_par3d_cuda() if not (ok1 and ok2 and ok3): raise RuntimeError("Test failed") + +def test(): + """Perform a very basic functionality test""" + + import astra + if astra.use_cuda(): + test_CUDA() + else: + print("No GPU support available") + test_noCUDA() -- cgit v1.2.3