Skip to content
Snippets Groups Projects
Commit 8b7d2857 authored by Philipp Arras's avatar Philipp Arras
Browse files

Cosmetics

parent cb0b29db
No related branches found
No related tags found
1 merge request!415CorrelatedFieldMaker: offset parametrization in one place
Pipeline #71430 passed
...@@ -31,7 +31,7 @@ import nifty6 as ift ...@@ -31,7 +31,7 @@ import nifty6 as ift
@pytest.mark.parametrize('rseed', [13, 2]) @pytest.mark.parametrize('rseed', [13, 2])
@pytest.mark.parametrize('Astds', [[1., 3.], [0.2, 1.4]]) @pytest.mark.parametrize('Astds', [[1., 3.], [0.2, 1.4]])
@pytest.mark.parametrize('offset_std_mean', [1., 10.]) @pytest.mark.parametrize('offset_std_mean', [1., 10.])
@pytest.mark.parametrize('N', [0,2]) @pytest.mark.parametrize('N', [0, 2])
def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N): def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N):
def stats(op, samples): def stats(op, samples):
sc = ift.StatCalculator() sc = ift.StatCalculator()
...@@ -43,18 +43,16 @@ def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N): ...@@ -43,18 +43,16 @@ def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N):
nsam = 100 nsam = 100
fsspace = ift.RGSpace((12,), (0.4,)) fsspace = ift.RGSpace((12,), (0.4,))
if N==2: if N == 2:
dofdex1 = [0,0] dofdex1 = [0, 0]
dofdex2 = [1,0] dofdex2 = [1, 0]
dofdex3 = [1,1] dofdex3 = [1, 1]
else: else:
dofdex1, dofdex2, dofdex3 = None, None, None dofdex1, dofdex2, dofdex3 = None, None, None
fa = ift.CorrelatedFieldMaker.make(0., offset_std_mean, 1E-8, '', N, dofdex1) fa = ift.CorrelatedFieldMaker.make(0., offset_std_mean, 1E-8, '', N, dofdex1)
fa.add_fluctuations(sspace, Astds[0], 1E-8, 1.1, 2., 2.1, .5, -2, 1., fa.add_fluctuations(sspace, Astds[0], 1E-8, 1.1, 2., 2.1, .5, -2, 1., 'spatial', dofdex=dofdex2)
'spatial', dofdex = dofdex2) fa.add_fluctuations(fsspace, Astds[1], 1E-8, 3.1, 1., .5, .1, -4, 1., 'freq', dofdex=dofdex3)
fa.add_fluctuations(fsspace, Astds[1], 1E-8, 3.1, 1., .5, .1, -4, 1.,
'freq', dofdex = dofdex3)
op = fa.finalize() op = fa.finalize()
samples = [ift.from_random('normal', op.domain) for _ in range(nsam)] samples = [ift.from_random('normal', op.domain) for _ in range(nsam)]
...@@ -82,14 +80,13 @@ def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N): ...@@ -82,14 +80,13 @@ def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N):
assert_allclose(slice_fluct_std1, sl_fluct_freq, rtol=0.5) assert_allclose(slice_fluct_std1, sl_fluct_freq, rtol=0.5)
fa = ift.CorrelatedFieldMaker.make(0., offset_std_mean, .1, '', N, dofdex1) fa = ift.CorrelatedFieldMaker.make(0., offset_std_mean, .1, '', N, dofdex1)
fa.add_fluctuations(fsspace, Astds[1], 1., 3.1, 1., .5, .1, -4, 1., 'freq', dofdex = dofdex3) fa.add_fluctuations(fsspace, Astds[1], 1., 3.1, 1., .5, .1, -4, 1., 'freq', dofdex=dofdex3)
m = 3. m = 3.
x = fa.moment_slice_to_average(m) x = fa.moment_slice_to_average(m)
fa.add_fluctuations(sspace, x, 1.5, 1.1, 2., 2.1, .5, -2, 1., 'spatial', 0, dofdex = dofdex2) fa.add_fluctuations(sspace, x, 1.5, 1.1, 2., 2.1, .5, -2, 1., 'spatial', 0, dofdex=dofdex2)
op = fa.finalize() op = fa.finalize()
em, estd = stats(fa.slice_fluctuation(0), samples) em, estd = stats(fa.slice_fluctuation(0), samples)
assert_allclose(m, em, rtol=0.5) assert_allclose(m, em, rtol=0.5)
assert op.target[-2] == sspace assert op.target[-2] == sspace
assert op.target[-1] == fsspace assert op.target[-1] == fsspace
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment