summaryrefslogtreecommitdiffstats
path: root/python/astra
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-09-16 15:52:30 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-09-16 15:52:40 +0200
commit8144bf0397ee1913b830d82058ccd40df741f1b3 (patch)
tree7f707615c104621226fd8bdd868f86aee8e5bd73 /python/astra
parent47b520d51fc4fc49db992b9117f6c0abfa8152b5 (diff)
parentc1713c00c4aeae594913667d868106e8591dd1d1 (diff)
downloadastra-8144bf0397ee1913b830d82058ccd40df741f1b3.tar.gz
astra-8144bf0397ee1913b830d82058ccd40df741f1b3.tar.bz2
astra-8144bf0397ee1913b830d82058ccd40df741f1b3.tar.xz
astra-8144bf0397ee1913b830d82058ccd40df741f1b3.zip
Merge branch 'master'
Diffstat (limited to 'python/astra')
-rw-r--r--python/astra/PyIncludes.pxd2
-rw-r--r--python/astra/algorithm_c.pyx4
-rw-r--r--python/astra/log_c.pyx8
-rw-r--r--python/astra/optomo.py18
4 files changed, 25 insertions, 7 deletions
diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd
index 909f58f..35dea5f 100644
--- a/python/astra/PyIncludes.pxd
+++ b/python/astra/PyIncludes.pxd
@@ -143,7 +143,7 @@ cdef extern from "astra/Float32ProjectionData2D.h" namespace "astra":
cdef extern from "astra/Algorithm.h" namespace "astra":
cdef cppclass CAlgorithm:
bool initialize(Config)
- void run(int)
+ void run(int) nogil
bool isInitialized()
cdef extern from "astra/ReconstructionAlgorithm2D.h" namespace "astra":
diff --git a/python/astra/algorithm_c.pyx b/python/astra/algorithm_c.pyx
index 966d3d7..3231c1f 100644
--- a/python/astra/algorithm_c.pyx
+++ b/python/astra/algorithm_c.pyx
@@ -73,7 +73,9 @@ cdef CAlgorithm * getAlg(i) except NULL:
def run(i, iterations=0):
cdef CAlgorithm * alg = getAlg(i)
- alg.run(iterations)
+ cdef int its = iterations
+ with nogil:
+ alg.run(its)
def get_res_norm(i):
diff --git a/python/astra/log_c.pyx b/python/astra/log_c.pyx
index f16329f..55c63e6 100644
--- a/python/astra/log_c.pyx
+++ b/python/astra/log_c.pyx
@@ -53,19 +53,19 @@ cdef extern from "astra/Logging.h" namespace "astra::CLogger":
def log_debug(sfile, sline, message):
cstr = list(map(six.b,(sfile,message)))
- debug(cstr[0],sline,cstr[1])
+ debug(cstr[0],sline,"%s",<char*>cstr[1])
def log_info(sfile, sline, message):
cstr = list(map(six.b,(sfile,message)))
- info(cstr[0],sline,cstr[1])
+ info(cstr[0],sline,"%s",<char*>cstr[1])
def log_warn(sfile, sline, message):
cstr = list(map(six.b,(sfile,message)))
- warn(cstr[0],sline,cstr[1])
+ warn(cstr[0],sline,"%s",<char*>cstr[1])
def log_error(sfile, sline, message):
cstr = list(map(six.b,(sfile,message)))
- error(cstr[0],sline,cstr[1])
+ error(cstr[0],sline,"%s",<char*>cstr[1])
def log_enable():
enable()
diff --git a/python/astra/optomo.py b/python/astra/optomo.py
index 0108674..4a64150 100644
--- a/python/astra/optomo.py
+++ b/python/astra/optomo.py
@@ -86,7 +86,15 @@ class OpTomo(scipy.sparse.linalg.LinearOperator):
self.proj_id = proj_id
- self.T = OpTomoTranspose(self)
+ self.transposeOpTomo = OpTomoTranspose(self)
+ try:
+ self.T = self.transposeOpTomo
+ except AttributeError:
+ # Scipy >= 0.16 defines self.T using self._transpose()
+ pass
+
+ def _transpose(self):
+ return self.transposeOpTomo
def __checkArray(self, arr, shp):
if len(arr.shape)==1:
@@ -189,6 +197,11 @@ class OpTomoTranspose(scipy.sparse.linalg.LinearOperator):
self.parent = parent
self.dtype = np.float32
self.shape = (parent.shape[1], parent.shape[0])
+ try:
+ self.T = self.parent
+ except AttributeError:
+ # Scipy >= 0.16 defines self.T using self._transpose()
+ pass
def _matvec(self, s):
return self.parent.rmatvec(s)
@@ -196,6 +209,9 @@ class OpTomoTranspose(scipy.sparse.linalg.LinearOperator):
def rmatvec(self, v):
return self.parent.matvec(v)
+ def _transpose(self):
+ return self.parent
+
def __mul__(self,s):
# Catch the case of a backprojection of 2D/3D data
if isinstance(s, np.ndarray) and s.shape==self.parent.sshape: