diff options
author | Willem Jan Palenstijn <wjp@usecode.org> | 2016-04-15 17:00:31 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <wjp@usecode.org> | 2016-04-15 17:00:31 +0200 |
commit | 80bfa4774a408f109dd49a985a22ff64b08ce1df (patch) | |
tree | 330cce11dfeb228b9df788720b4fdf2c79eb003c /python/astra/astra_c.pyx | |
parent | 7633a0f48ce030413642627f16e50d27da4cf709 (diff) | |
parent | 7b8a508f0bc7a8a02766b15fa094dfd18c1b0525 (diff) | |
download | astra-80bfa4774a408f109dd49a985a22ff64b08ce1df.tar.gz astra-80bfa4774a408f109dd49a985a22ff64b08ce1df.tar.bz2 astra-80bfa4774a408f109dd49a985a22ff64b08ce1df.tar.xz astra-80bfa4774a408f109dd49a985a22ff64b08ce1df.zip |
Merge pull request #29 from wjp/indexmanager
Add an AstraIndexManager
Diffstat (limited to 'python/astra/astra_c.pyx')
-rw-r--r-- | python/astra/astra_c.pyx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx index baad853..8e30e69 100644 --- a/python/astra/astra_c.pyx +++ b/python/astra/astra_c.pyx @@ -33,6 +33,9 @@ from .utils import wrap_from_bytes from libcpp.string cimport string from libcpp.vector cimport vector from libcpp cimport bool +cimport PyIndexManager +from .PyIndexManager cimport CAstraObjectManagerBase + cdef extern from "astra/Globals.h" namespace "astra": int getVersion() string getVersionString() @@ -51,6 +54,7 @@ cdef extern from "astra/CompositeGeometryManager.h" namespace "astra": cdef extern from "astra/CompositeGeometryManager.h" namespace "astra::CCompositeGeometryManager": void setGlobalGPUParams(SGPUParams&) + def credits(): six.print_("""The ASTRA Toolbox has been developed at the University of Antwerp and CWI, Amsterdam by * Prof. dr. Joost Batenburg @@ -79,11 +83,10 @@ def version(printToScreen=False): IF HAVE_CUDA==True: def set_gpu_index(idx, memory=0): - import types import collections cdef SGPUParams params if use_cuda()==True: - if not isinstance(idx, collections.Iterable) or isinstance(idx, types.StringTypes): + if not isinstance(idx, collections.Iterable) or isinstance(idx, six.string_types + (six.text_type,six.binary_type)): idx = (idx,) params.memory = memory params.GPUIndices = idx @@ -94,3 +97,24 @@ IF HAVE_CUDA==True: ELSE: def set_gpu_index(idx, memory=0): raise NotImplementedError("CUDA support is not enabled in ASTRA") + +def delete(ids): + import collections + cdef CAstraObjectManagerBase* ptr + if not isinstance(ids, collections.Iterable) or isinstance(ids, six.string_types + (six.text_type,six.binary_type)): + ids = (ids,) + for i in ids: + ptr = PyIndexManager.getSingletonPtr().get(i) + if ptr: + ptr.remove(i) + +def info(ids): + import collections + cdef CAstraObjectManagerBase* ptr + if not isinstance(ids, collections.Iterable) or isinstance(ids, six.string_types + (six.text_type,six.binary_type)): + ids = (ids,) + for i in ids: + ptr = PyIndexManager.getSingletonPtr().get(i) + if ptr: + s = ptr.getType() + six.b("\t") + ptr.getInfo(i) + six.print_(wrap_from_bytes(s)) |