Commit 1912a03e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

updates

parent 3b99cb81
......@@ -132,7 +132,7 @@ class SmoothingOperator(EndomorphicOperator):
if smooth_length == 0.0:
return power[startindex:endindex]
p_smooth = np.empty(endindex-startindex, dtype=np.float64)
p_smooth = np.empty(endindex-startindex, dtype=power.dtype)
for i in xrange(startindex, endindex):
p_smooth[i-startindex]=np.sum(power[ibegin[i]:ibegin[i]+nval[i]]*wgt[i])
......@@ -178,7 +178,7 @@ class SmoothingOperator(EndomorphicOperator):
outshape = np.asarray(SmoothingOperator._getShape(arr))
outshape[axis] = endindex - startindex
outarr = np.zeros(outshape, dtype=np.float64)
outarr = np.zeros(outshape, dtype=arr.dtype)
outarr[tuple(i.tolist())] = res
k = 1
while k < Ntot:
......@@ -355,7 +355,6 @@ class SmoothingOperator(EndomorphicOperator):
else:
true_sigma = self.sigma
distances = distances.astype(np.float64, copy=False)
smoothed_data = SmoothingOperator._apply_along_axis(
data_axis, data,
startindex=true_start,
......
......@@ -28,7 +28,9 @@ from nifty import Field,\
LMSpace,\
HPSpace,\
GLSpace,\
FFTOperator
PowerSpace,\
FFTOperator,\
SmoothingOperator
from itertools import product
from test.common import expand
......@@ -158,3 +160,16 @@ class Misc_Tests(unittest.TestCase):
v1=np.sqrt(out.dot(out))
v2=np.sqrt(inp.dot(fft.adjoint_times(out)))
assert_allclose(v1,v2, rtol=tol, atol=tol)
@expand(product([100,200],[False,True],[0.,1.,3.7],
[np.float64,np.complex128]))
def test_smooth(self, sz, log, sigma, tp):
tol = _get_rtol(tp)
sp=RGSpace(sz,harmonic=True)
ps=PowerSpace(sp,nbin=sz,logarithmic=log)
smo=SmoothingOperator(ps,sigma=sigma)
inp = Field.from_random(domain=ps, random_type='normal', std=1, mean=4,
dtype=tp)
out=smo(inp)
inp=inp.val.get_full_data()
assert_allclose(inp.sum(),out.sum(), rtol=tol, atol=tol)
Supports Markdown
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