Commit 1822081e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweak array flattening

parent 1ee9020b
......@@ -735,7 +735,7 @@ class Field(object):
y = self if bare else self.weight(power=1)
if spaces is None:
return np.vdot(y.val.flatten(), x.val.flatten())
return np.vdot(y.val.reshape(-1), x.val.reshape(-1))
else:
# create a diagonal operator which is capable of taking care of the
# axes-matching
......
......@@ -299,7 +299,7 @@ class LineSearchStrongWolfe(LineSearch):
d1[1, 0] = -(dc*dc*dc)
d1[1, 1] = db*db*db
[A, B] = np.dot(d1, np.asarray([fb - fa - C * db,
fc - fa - C * dc]).flatten())
fc - fa - C * dc]).reshape(-1))
A /= denom
B /= denom
radical = B * B - 3 * A * C
......
......@@ -114,7 +114,7 @@ class GLSpace(Space):
def weight(self):
from pyHealpix import GL_weights
vol = GL_weights(self.nlat, self.nlon)
return np.outer(vol, np.ones(self.nlon,dtype=np.float64)).flatten()
return np.outer(vol, np.ones(self.nlon,dtype=np.float64)).reshape(-1)
# ---Added properties and methods---
......
......@@ -162,10 +162,11 @@ class PowerSpace(Space):
harmonic_partner=self.harmonic_partner,
distance_array=distance_array,
binbounds=binbounds)
temp_rho = np.bincount(temp_pindex.flatten())
temp_rho = np.bincount(temp_pindex.reshape(-1))
assert not np.any(temp_rho == 0), "empty bins detected"
temp_kindex = np.bincount(temp_pindex.flatten(),
weights=distance_array.flatten()) / temp_rho
temp_kindex = np.bincount(temp_pindex.reshape(-1),
weights=distance_array.reshape(-1)) \
/ temp_rho
self._powerIndexCache[key] = (binbounds,
temp_pindex,
temp_kindex,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment