summaryrefslogtreecommitdiffstats
path: root/python/astra/data3d.py
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2017-02-09 18:01:03 +0100
committerGitHub <noreply@github.com>2017-02-09 18:01:03 +0100
commit981d6adc0e3c98a67403b92b1ec4cdb881c62fda (patch)
treecccde0fd4a3a2d92919338df4e162c9abfd079e1 /python/astra/data3d.py
parent03c3e5b5043cc8cba9aceeb8641d497edd1be7cf (diff)
parent4c665b0d5af3841f20501a5dc01a23e671367856 (diff)
downloadastra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.gz
astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.bz2
astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.xz
astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.zip
Merge pull request #93 from wjp/GPULink
GPULink support
Diffstat (limited to 'python/astra/data3d.py')
-rw-r--r--python/astra/data3d.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/python/astra/data3d.py b/python/astra/data3d.py
index 9c2bea4..ecb99d0 100644
--- a/python/astra/data3d.py
+++ b/python/astra/data3d.py
@@ -26,6 +26,8 @@
from . import data3d_c as d
import numpy as np
+from .pythonutils import GPULink
+
def create(datatype,geometry,data=None):
"""Create a 3D object.
@@ -52,12 +54,13 @@ def link(datatype, geometry, data):
:returns: :class:`int` -- the ID of the constructed object.
"""
- if not isinstance(data,np.ndarray):
- raise ValueError("Input should be a numpy array")
- if not data.dtype==np.float32:
- raise ValueError("Numpy array should be float32")
- if not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']):
- raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED")
+ if not isinstance(data,np.ndarray) and not isinstance(data,GPULink):
+ raise TypeError("Input should be a numpy ndarray or GPULink object")
+ if isinstance(data, np.ndarray):
+ if data.dtype != np.float32:
+ raise ValueError("Numpy array should be float32")
+ if not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']):
+ raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED")
return d.create(datatype,geometry,data,True)