summaryrefslogtreecommitdiffstats
path: root/python/astra/data3d.py
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-02-08 11:31:31 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-02-08 16:17:19 +0100
commit2af27e7ba08a65cce15c7e0658712fbba8f447fd (patch)
treec53477fad8f0a71d5dcb7a05faf5d86ae8bee920 /python/astra/data3d.py
parentae33f713a2dea236e28145dcd6007589feb618ed (diff)
downloadastra-2af27e7ba08a65cce15c7e0658712fbba8f447fd.tar.gz
astra-2af27e7ba08a65cce15c7e0658712fbba8f447fd.tar.bz2
astra-2af27e7ba08a65cce15c7e0658712fbba8f447fd.tar.xz
astra-2af27e7ba08a65cce15c7e0658712fbba8f447fd.zip
Improve data2d/data3d error messages
Diffstat (limited to 'python/astra/data3d.py')
-rw-r--r--python/astra/data3d.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/python/astra/data3d.py b/python/astra/data3d.py
index a825700..ecb99d0 100644
--- a/python/astra/data3d.py
+++ b/python/astra/data3d.py
@@ -55,11 +55,12 @@ def link(datatype, geometry, data):
"""
if not isinstance(data,np.ndarray) and not isinstance(data,GPULink):
- raise ValueError("Input should be a numpy array")
- if not isinstance(data,GPULink) and not data.dtype==np.float32:
- raise ValueError("Numpy array should be float32")
- if not isinstance(data,GPULink) and not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']):
- raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED")
+ 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)