summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-09-25 18:24:57 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-09-25 18:42:16 +0200
commit03ff113ac48f21956247b164a83000b5f6ab311d (patch)
treee0f98656f13716b42898c6aefd8abbcc7353d4bc /python
parentbd5abc1dd5162ead6e0d19fb8f575bc61fcbc6c0 (diff)
downloadastra-03ff113ac48f21956247b164a83000b5f6ab311d.tar.gz
astra-03ff113ac48f21956247b164a83000b5f6ab311d.tar.bz2
astra-03ff113ac48f21956247b164a83000b5f6ab311d.tar.xz
astra-03ff113ac48f21956247b164a83000b5f6ab311d.zip
Add support for checking features at run-time
Diffstat (limited to 'python')
-rw-r--r--python/astra/__init__.py2
-rw-r--r--python/astra/astra.py14
-rw-r--r--python/astra/astra_c.pyx8
3 files changed, 22 insertions, 2 deletions
diff --git a/python/astra/__init__.py b/python/astra/__init__.py
index 1a7f444..ae35316 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, geom_size, geom_2vec, geom_postalignment
from .extrautils import clipCircle
-from .astra import set_gpu_index, get_gpu_info, use_cuda
+from .astra import set_gpu_index, get_gpu_info, use_cuda, has_feature
from . import data2d
from . import astra
from . import data3d
diff --git a/python/astra/astra.py b/python/astra/astra.py
index ef46db1..e74d29a 100644
--- a/python/astra/astra.py
+++ b/python/astra/astra.py
@@ -54,6 +54,20 @@ def get_gpu_info(idx=-1):
"""
return a.get_gpu_info(idx)
+def has_feature(feature):
+ """Check a feature flag.
+
+ These are used to check if certain functionality has been
+ enabled at compile time, if new functionality is present, or if
+ a backward-incompatible change is present.
+
+ See include/astra/Features.h for a list.
+
+ :param feature: The name of the feature
+ :type feature: :class:`str`
+ :returns: :class:`bool` -- The presence of the feature
+ """
+ return a.has_feature(feature)
def delete(ids):
"""Delete an astra object.
diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx
index 65dbf28..69909b5 100644
--- a/python/astra/astra_c.pyx
+++ b/python/astra/astra_c.pyx
@@ -28,7 +28,7 @@
include "config.pxi"
import six
-from .utils import wrap_from_bytes
+from .utils import wrap_from_bytes, wrap_to_bytes
from libcpp.string cimport string
from libcpp.vector cimport vector
@@ -40,6 +40,9 @@ cdef extern from "astra/Globals.h" namespace "astra":
bool cudaEnabled()
bool cudaAvailable()
+cdef extern from "astra/Features.h" namespace "astra":
+ bool hasFeature(string)
+
IF HAVE_CUDA==True:
cdef extern from "astra/cuda/2d/astra.h" namespace "astraCUDA":
bool setGPUIndex(int)
@@ -120,3 +123,6 @@ def info(ids):
if ptr:
s = ptr.getType() + six.b("\t") + ptr.getInfo(i)
six.print_(wrap_from_bytes(s))
+
+def has_feature(feature):
+ return hasFeature(wrap_to_bytes(feature))