summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2016-04-25 11:22:49 +0200
committerWillem Jan Palenstijn <wjp@usecode.org>2016-04-25 11:22:49 +0200
commit3afc1cf2bfd03255390d4a8862dfe8d9a7086a9f (patch)
treeb6a494550b24896c10ffda19cdebe02b9c699221
parent8b67986464daae799d0171aed70a0d2cd96fd8d1 (diff)
parent1e26f7602b6685c584fd4d857353f390622e3a34 (diff)
downloadastra-3afc1cf2bfd03255390d4a8862dfe8d9a7086a9f.tar.gz
astra-3afc1cf2bfd03255390d4a8862dfe8d9a7086a9f.tar.bz2
astra-3afc1cf2bfd03255390d4a8862dfe8d9a7086a9f.tar.xz
astra-3afc1cf2bfd03255390d4a8862dfe8d9a7086a9f.zip
Merge pull request #49 from dmpelt/flatten_to_ravel
Change flatten to ravel in Python code
-rw-r--r--python/astra/optomo.py4
-rw-r--r--samples/python/s009_projection_matrix.py2
-rw-r--r--samples/python/s015_fp_bp.py6
-rw-r--r--samples/python/s017_OpTomo.py2
4 files changed, 7 insertions, 7 deletions
diff --git a/python/astra/optomo.py b/python/astra/optomo.py
index dd10713..5a92998 100644
--- a/python/astra/optomo.py
+++ b/python/astra/optomo.py
@@ -125,7 +125,7 @@ class OpTomo(scipy.sparse.linalg.LinearOperator):
algorithm.delete(fp_id)
self.data_mod.delete([vid,sid])
- return s.flatten()
+ return s.ravel()
def rmatvec(self,s):
"""Implements the transpose operator.
@@ -147,7 +147,7 @@ class OpTomo(scipy.sparse.linalg.LinearOperator):
algorithm.delete(bp_id)
self.data_mod.delete([vid,sid])
- return v.flatten()
+ return v.ravel()
def __mul__(self,v):
"""Provides easy forward operator by *.
diff --git a/samples/python/s009_projection_matrix.py b/samples/python/s009_projection_matrix.py
index c4c4557..e20d58c 100644
--- a/samples/python/s009_projection_matrix.py
+++ b/samples/python/s009_projection_matrix.py
@@ -46,7 +46,7 @@ W = astra.matrix.get(matrix_id)
# Manually use this projection matrix to do a projection:
import scipy.io
P = scipy.io.loadmat('phantom.mat')['phantom256']
-s = W.dot(P.flatten())
+s = W.dot(P.ravel())
s = np.reshape(s, (len(proj_geom['ProjectionAngles']),proj_geom['DetectorCount']))
import pylab
diff --git a/samples/python/s015_fp_bp.py b/samples/python/s015_fp_bp.py
index fa0bf86..ff0b30a 100644
--- a/samples/python/s015_fp_bp.py
+++ b/samples/python/s015_fp_bp.py
@@ -46,12 +46,12 @@ class astra_wrap(object):
def matvec(self,v):
sid, s = astra.create_sino(np.reshape(v,(vol_geom['GridRowCount'],vol_geom['GridColCount'])),self.proj_id)
astra.data2d.delete(sid)
- return s.flatten()
+ return s.ravel()
def rmatvec(self,v):
bid, b = astra.create_backprojection(np.reshape(v,(len(proj_geom['ProjectionAngles']),proj_geom['DetectorCount'],)),self.proj_id)
astra.data2d.delete(bid)
- return b.flatten()
+ return b.ravel()
vol_geom = astra.create_vol_geom(256, 256)
proj_geom = astra.create_proj_geom('parallel', 1.0, 384, np.linspace(0,np.pi,180,False))
@@ -65,7 +65,7 @@ proj_id = astra.create_projector('cuda',proj_geom,vol_geom)
sinogram_id, sinogram = astra.create_sino(P, proj_id)
# Reshape the sinogram into a vector
-b = sinogram.flatten()
+b = sinogram.ravel()
# Call lsqr with ASTRA FP and BP
import scipy.sparse.linalg
diff --git a/samples/python/s017_OpTomo.py b/samples/python/s017_OpTomo.py
index 967fa64..214e9a7 100644
--- a/samples/python/s017_OpTomo.py
+++ b/samples/python/s017_OpTomo.py
@@ -50,7 +50,7 @@ pylab.figure(2)
pylab.imshow(sinogram)
# Run the lsqr linear solver
-output = scipy.sparse.linalg.lsqr(W, sinogram.flatten(), iter_lim=150)
+output = scipy.sparse.linalg.lsqr(W, sinogram.ravel(), iter_lim=150)
rec = output[0].reshape([256, 256])
pylab.figure(3)