Commit 36600a91 by Martin Reinecke

### PEP8

parent b87abe36
Pipeline #16755 passed with stage
in 25 minutes and 7 seconds
 ... ... @@ -27,10 +27,10 @@ import nifty.nifty_utilities as utilities class LaplaceOperator(EndomorphicOperator): """A irregular LaplaceOperator with free boundary and excluding monopole. This LaplaceOperator implements the second derivative of a Field in PowerSpace on logarithmic or linear scale with vanishing curvature at the boundary, starting at the second entry of the Field. The second derivative of the Field on the irregular grid is calculated using finite differences. This LaplaceOperator implements the second derivative of a Field in PowerSpace on logarithmic or linear scale with vanishing curvature at the boundary, starting at the second entry of the Field. The second derivative of the Field on the irregular grid is calculated using finite differences. Parameters ---------- ... ... @@ -60,9 +60,9 @@ class LaplaceOperator(EndomorphicOperator): # for convenience, but they will never affect the result) self._dposc = np.empty_like(pos) self._dposc[:-1] = self._dpos self._dposc[-1]=0. self._dposc[1:]+=self._dpos self._dposc*=0.5 self._dposc[-1] = 0. self._dposc[1:] += self._dpos self._dposc *= 0.5 @property def target(self): ... ... @@ -100,8 +100,8 @@ class LaplaceOperator(EndomorphicOperator): axis = axes[0] nval = len(self._dposc) prefix = (slice(None),) * axis sl_l = prefix + (slice(None,-1),) # "left" slice sl_r = prefix + (slice(1,None),) # "right" slice sl_l = prefix + (slice(None, -1),) # "left" slice sl_r = prefix + (slice(1, None),) # "right" slice dpos = self._dpos.reshape((1,)*axis + (nval-1,)) dposc = self._dposc.reshape((1,)*axis + (nval,)) deriv = (x.val[sl_r]-x.val[sl_l])/dpos # defined between points ... ... @@ -110,7 +110,7 @@ class LaplaceOperator(EndomorphicOperator): ret[prefix + (-1,)] = 0. ret[sl_r] -= deriv ret /= sqrt(dposc) ret[prefix + (slice(None,2),)] = 0. ret[prefix + (slice(None, 2),)] = 0. ret[prefix + (-1,)] = 0. return Field(self.domain, val=ret).weight(power=-0.5, spaces=spaces) ... ... @@ -126,8 +126,8 @@ class LaplaceOperator(EndomorphicOperator): axis = axes[0] nval = len(self._dposc) prefix = (slice(None),) * axis sl_l = prefix + (slice(None,-1),) # "left" slice sl_r = prefix + (slice(1,None),) # "right" slice sl_l = prefix + (slice(None, -1),) # "left" slice sl_r = prefix + (slice(1, None),) # "right" slice dpos = self._dpos.reshape((1,)*axis + (nval-1,)) dposc = self._dposc.reshape((1,)*axis + (nval,)) y = x.copy().weight(power=0.5).val ... ...
 ... ... @@ -19,19 +19,17 @@ import unittest import numpy as np import nifty as ift from numpy.testing import assert_equal,\ assert_allclose from numpy.testing import assert_allclose from itertools import product from test.common import expand from nose.plugins.skip import SkipTest class LaplaceOperatorTests(unittest.TestCase): @expand(product([None,False,True], [False,True], [10,100,1000])) @expand(product([None, False, True], [False, True], [10, 100, 1000])) def test_Laplace(self, log1, log2, sz): s=ift.RGSpace(sz,harmonic=True) p=ift.PowerSpace(s,logarithmic=log1) L=ift.LaplaceOperator(p,logarithmic=log2) arr=np.random.random(p.shape[0]) fp=ift.Field(p,val=arr) assert_allclose (L(fp).vdot(L(fp)),L.adjoint_times(L(fp)).vdot(fp)) s = ift.RGSpace(sz, harmonic=True) p = ift.PowerSpace(s, logarithmic=log1) L = ift.LaplaceOperator(p, logarithmic=log2) arr = np.random.random(p.shape[0]) fp = ift.Field(p, val=arr) assert_allclose(L(fp).vdot(L(fp)), L.adjoint_times(L(fp)).vdot(fp))
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