From 55be306e59ac5aed699eb9da617967ff4c08a625 Mon Sep 17 00:00:00 2001 From: Martin Reinecke <martin@mpa-garching.mpg.de> Date: Thu, 7 Sep 2017 10:29:10 +0200 Subject: [PATCH] reshape(-1) -> ravel() --- nifty2go/field.py | 2 +- .../minimization/line_searching/line_search_strong_wolfe.py | 2 +- nifty2go/spaces/gl_space/gl_space.py | 2 +- nifty2go/spaces/power_space/power_space.py | 6 +++--- test/test_spaces/test_power_space.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nifty2go/field.py b/nifty2go/field.py index 754f01010..d6d607ccc 100644 --- a/nifty2go/field.py +++ b/nifty2go/field.py @@ -706,7 +706,7 @@ class Field(object): fct = tmp if spaces is None: - return fct*np.vdot(y.val.reshape(-1), x.val.reshape(-1)) + return fct*np.vdot(y.val.ravel(), x.val.ravel()) else: # create a diagonal operator which is capable of taking care of the # axes-matching diff --git a/nifty2go/minimization/line_searching/line_search_strong_wolfe.py b/nifty2go/minimization/line_searching/line_search_strong_wolfe.py index bbee6703e..ad321f4f1 100644 --- a/nifty2go/minimization/line_searching/line_search_strong_wolfe.py +++ b/nifty2go/minimization/line_searching/line_search_strong_wolfe.py @@ -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]).reshape(-1)) + fc - fa - C * dc]).ravel()) A /= denom B /= denom radical = B * B - 3 * A * C diff --git a/nifty2go/spaces/gl_space/gl_space.py b/nifty2go/spaces/gl_space/gl_space.py index 5bb00aafb..06c24abfc 100644 --- a/nifty2go/spaces/gl_space/gl_space.py +++ b/nifty2go/spaces/gl_space/gl_space.py @@ -117,7 +117,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)).reshape(-1) + return np.outer(vol, np.ones(self.nlon,dtype=np.float64)).ravel() # ---Added properties and methods--- diff --git a/nifty2go/spaces/power_space/power_space.py b/nifty2go/spaces/power_space/power_space.py index 1d1f9f03c..62657069f 100644 --- a/nifty2go/spaces/power_space/power_space.py +++ b/nifty2go/spaces/power_space/power_space.py @@ -162,10 +162,10 @@ class PowerSpace(Space): harmonic_partner=self.harmonic_partner, distance_array=distance_array, binbounds=binbounds) - temp_rho = np.bincount(temp_pindex.reshape(-1)) + temp_rho = np.bincount(temp_pindex.ravel()) assert not np.any(temp_rho == 0), "empty bins detected" - temp_kindex = np.bincount(temp_pindex.reshape(-1), - weights=distance_array.reshape(-1)) \ + temp_kindex = np.bincount(temp_pindex.ravel(), + weights=distance_array.ravel()) \ / temp_rho self._powerIndexCache[key] = (binbounds, temp_pindex, diff --git a/test/test_spaces/test_power_space.py b/test/test_spaces/test_power_space.py index 8e7e01dd1..f150c4463 100644 --- a/test/test_spaces/test_power_space.py +++ b/test/test_spaces/test_power_space.py @@ -101,7 +101,7 @@ class PowerSpaceConsistencyCheck(unittest.TestCase): bb = PowerSpace.useful_binbounds(harmonic_partner, logarithmic, nbin) p = PowerSpace(harmonic_partner=harmonic_partner, binbounds=bb) - assert_equal(np.bincount(p.pindex.reshape(-1)), p.rho, + assert_equal(np.bincount(p.pindex.ravel()), p.rho, err_msg='rho is not equal to pindex degeneracy') -- GitLab