Commit 05d1d092 by Theo Steininger

### Merge branch 'fight_the_power' into 'master'

```replace ** with clearer operators where possible

See merge request !149```
parents f0b59b53 9879e567
Pipeline #13331 passed with stages
in 11 minutes and 23 seconds
 ... ... @@ -65,7 +65,6 @@ class LineSearchStrongWolfe(LineSearch): max_step_size=50, max_iterations=10, max_zoom_iterations=10): super(LineSearchStrongWolfe, self).__init__() self.c1 = np.float(c1) ... ... @@ -308,7 +307,8 @@ class LineSearchStrongWolfe(LineSearch): """Estimating the minimum with cubic interpolation. Finds the minimizer for a cubic polynomial that goes through the points ( a,f(a) ), ( b,f(b) ), and ( c,f(c) ) with derivative at point a of fpa. points ( a,f(a) ), ( b,f(b) ), and ( c,f(c) ) with derivative at point a of fpa. f(x) = A *(x-a)^3 + B*(x-a)^2 + C*(x-a) + D If no minimizer can be found return None ... ... @@ -341,12 +341,12 @@ class LineSearchStrongWolfe(LineSearch): C = fpa db = b - a dc = c - a denom = (db * dc) ** 2 * (db - dc) denom = db * db * dc * dc * (db - dc) d1 = np.empty((2, 2)) d1[0, 0] = dc ** 2 d1[0, 1] = -db ** 2 d1[1, 0] = -dc ** 3 d1[1, 1] = db ** 3 d1[0, 0] = dc * dc d1[0, 1] = -(db*db) 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()) A /= denom ... ...
 ... ... @@ -118,7 +118,7 @@ class RGRGTransformation(Transformation): np.absolute(np.array(domain.shape) * np.array(domain.distances) * np.array(codomain.distances) - 1) < 10**-7): 1e-7): raise AttributeError("The grid-distances of domain and codomain " "do not match.") ... ...
 ... ... @@ -93,11 +93,11 @@ class HPSpace(Space): @property def shape(self): return (np.int(12 * self.nside ** 2),) return (np.int(12 * self.nside * self.nside),) @property def dim(self): return np.int(12 * self.nside ** 2) return np.int(12 * self.nside * self.nside) @property def total_volume(self): ... ... @@ -108,7 +108,7 @@ class HPSpace(Space): def weight(self, x, power=1, axes=None, inplace=False): weight = ((4 * np.pi) / (12 * self.nside**2)) ** np.float(power) weight = ((4*np.pi) / (12*self.nside*self.nside)) ** np.float(power) if inplace: x *= weight ... ...
 ... ... @@ -130,7 +130,7 @@ class LMSpace(Space): # dim = (((2*(l+1)-1)+1)**2/4 - 2 * (l-m)(l-m+1)/2 # dim = np.int((l+1)**2 - (l-m)*(l-m+1.)) # We fix l == m return np.int((l+1)**2) return np.int((l+1)*(l+1)) @property def total_volume(self): ... ... @@ -166,7 +166,7 @@ class LMSpace(Space): def get_fft_smoothing_kernel_function(self, sigma): # FIXME why x(x+1) ? add reference to paper! return lambda x: np.exp(-0.5 * x * (x + 1) * sigma**2) return lambda x: np.exp(-0.5 * x * (x + 1) * sigma*sigma) # ---Added properties and methods--- ... ...
 ... ... @@ -267,14 +267,16 @@ class RGSpace(Space): cords = np.ogrid[inds] dists = ((cords[0] - shape[0]//2)*dk[0])**2 dists = (cords[0] - shape[0]//2)*dk[0] dists *= dists # apply zerocenterQ shift if not self.zerocenter[0]: dists = np.fft.ifftshift(dists) # only save the individual slice dists = dists[slice_of_first_dimension] for ii in range(1, len(shape)): temp = ((cords[ii] - shape[ii] // 2) * dk[ii])**2 temp = (cords[ii] - shape[ii] // 2) * dk[ii] temp *= temp if not self.zerocenter[ii]: temp = np.fft.ifftshift(temp) dists = dists + temp ... ... @@ -282,7 +284,7 @@ class RGSpace(Space): return dists def get_fft_smoothing_kernel_function(self, sigma): return lambda x: np.exp(-0.5 * np.pi**2 * x**2 * sigma**2) return lambda x: np.exp(-0.5 * np.pi*np.pi * x*x * sigma*sigma) # ---Added properties and methods--- ... ...
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