summaryrefslogtreecommitdiffstats
path: root/python/astra/data2d_c.pyx
diff options
context:
space:
mode:
authorDaan Pelt <daan.pelt@gmail.com>2015-04-30 11:02:50 +0200
committerDaan Pelt <daan.pelt@gmail.com>2015-04-30 11:56:09 +0200
commitf69d9f6bc1704560518da3c30c46e495c0228aac (patch)
treeada5b18e9de0b195c6df99103a62674ebe6eac38 /python/astra/data2d_c.pyx
parent6fe3adab8ef3c9ab93a92c132f9809851a4dda74 (diff)
downloadastra-f69d9f6bc1704560518da3c30c46e495c0228aac.tar.gz
astra-f69d9f6bc1704560518da3c30c46e495c0228aac.tar.bz2
astra-f69d9f6bc1704560518da3c30c46e495c0228aac.tar.xz
astra-f69d9f6bc1704560518da3c30c46e495c0228aac.zip
Check data size when using 'link' function in Python
Diffstat (limited to 'python/astra/data2d_c.pyx')
-rw-r--r--python/astra/data2d_c.pyx16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/astra/data2d_c.pyx b/python/astra/data2d_c.pyx
index ac54898..29548b5 100644
--- a/python/astra/data2d_c.pyx
+++ b/python/astra/data2d_c.pyx
@@ -47,6 +47,12 @@ from .PyIncludes cimport *
cimport utils
from .utils import wrap_from_bytes
+from .pythonutils import geom_size
+
+import operator
+
+from six.moves import reduce
+
cdef CData2DManager * man2d = <CData2DManager * >PyData2DManager.getSingletonPtr()
cdef extern from "CFloat32CustomPython.h":
@@ -71,6 +77,16 @@ def create(datatype, geometry, data=None, link=False):
cdef CProjectionGeometry2D * ppGeometry
cdef CFloat32Data2D * pDataObject2D
cdef CFloat32CustomMemory * pCustom
+
+ if link:
+ geomSize = geom_size(geometry)
+ if len(data.shape)==1:
+ if data.size!=reduce(operator.mul,geomSize):
+ raise Exception("The dimensions of the data do not match those specified in the geometry.")
+ else:
+ if data.shape!=geomSize:
+ raise Exception("The dimensions of the data do not match those specified in the geometry.")
+
if datatype == '-vol':
cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry)
pGeometry = new CVolumeGeometry2D()