Commit 6451fc0c authored by Martin Reinecke's avatar Martin Reinecke
Browse files

adjust tolerances in unit tests

parent ee9cf92b
Pipeline #76956 passed with stages
in 11 minutes and 48 seconds
...@@ -61,10 +61,10 @@ def test_studentt(field): ...@@ -61,10 +61,10 @@ def test_studentt(field):
if isinstance(field.domain, ift.MultiDomain): if isinstance(field.domain, ift.MultiDomain):
return return
energy = ift.StudentTEnergy(domain=field.domain, theta=.5) energy = ift.StudentTEnergy(domain=field.domain, theta=.5)
ift.extra.check_operator(energy, field, tol=1e-6) ift.extra.check_operator(energy, field)
theta = ift.from_random(field.domain, 'normal').exp() theta = ift.from_random(field.domain, 'normal').exp()
energy = ift.StudentTEnergy(domain=field.domain, theta=theta) energy = ift.StudentTEnergy(domain=field.domain, theta=theta)
ift.extra.check_operator(energy, field, tol=1e-6, ntries=ntries) ift.extra.check_operator(energy, field, ntries=ntries)
def test_hamiltonian_and_KL(field): def test_hamiltonian_and_KL(field):
...@@ -84,7 +84,7 @@ def test_variablecovariancegaussian(field): ...@@ -84,7 +84,7 @@ def test_variablecovariancegaussian(field):
dc = {'a': field, 'b': field.ptw("exp")} dc = {'a': field, 'b': field.ptw("exp")}
mf = ift.MultiField.from_dict(dc) mf = ift.MultiField.from_dict(dc)
energy = ift.VariableCovarianceGaussianEnergy(field.domain, 'a', 'b', np.float64) energy = ift.VariableCovarianceGaussianEnergy(field.domain, 'a', 'b', np.float64)
ift.extra.check_operator(energy, mf, tol=1e-6, ntries=ntries) ift.extra.check_operator(energy, mf, ntries=ntries)
energy(ift.Linearization.make_var(mf, want_metric=True)).metric.draw_sample() energy(ift.Linearization.make_var(mf, want_metric=True)).metric.draw_sample()
...@@ -93,7 +93,7 @@ def test_specialgamma(field): ...@@ -93,7 +93,7 @@ def test_specialgamma(field):
return return
energy = ift.operators.energy_operators._SpecialGammaEnergy(field) energy = ift.operators.energy_operators._SpecialGammaEnergy(field)
loc = ift.from_random(energy.domain).exp() loc = ift.from_random(energy.domain).exp()
ift.extra.check_operator(energy, loc, tol=1e-6, ntries=ntries) ift.extra.check_operator(energy, loc, ntries=ntries)
energy(ift.Linearization.make_var(loc, want_metric=True)).metric.draw_sample() energy(ift.Linearization.make_var(loc, want_metric=True)).metric.draw_sample()
...@@ -105,7 +105,7 @@ def test_inverse_gamma(field): ...@@ -105,7 +105,7 @@ def test_inverse_gamma(field):
d = ift.random.current_rng().normal(10, size=space.shape)**2 d = ift.random.current_rng().normal(10, size=space.shape)**2
d = ift.Field(space, d) d = ift.Field(space, d)
energy = ift.InverseGammaLikelihood(d) energy = ift.InverseGammaLikelihood(d)
ift.extra.check_operator(energy, field, tol=1e-5) ift.extra.check_operator(energy, field, tol=1e-10)
def testPoissonian(field): def testPoissonian(field):
...@@ -116,7 +116,7 @@ def testPoissonian(field): ...@@ -116,7 +116,7 @@ def testPoissonian(field):
d = ift.random.current_rng().poisson(120, size=space.shape) d = ift.random.current_rng().poisson(120, size=space.shape)
d = ift.Field(space, d) d = ift.Field(space, d)
energy = ift.PoissonianEnergy(d) energy = ift.PoissonianEnergy(d)
ift.extra.check_operator(energy, field, tol=1e-6) ift.extra.check_operator(energy, field)
def test_bernoulli(field): def test_bernoulli(field):
...@@ -127,4 +127,4 @@ def test_bernoulli(field): ...@@ -127,4 +127,4 @@ def test_bernoulli(field):
d = ift.random.current_rng().binomial(1, 0.1, size=space.shape) d = ift.random.current_rng().binomial(1, 0.1, size=space.shape)
d = ift.Field(space, d) d = ift.Field(space, d)
energy = ift.BernoulliEnergy(d) energy = ift.BernoulliEnergy(d)
ift.extra.check_operator(energy, field, tol=1e-5) ift.extra.check_operator(energy, field, tol=1e-10)
...@@ -125,7 +125,7 @@ def testDynamicModel(target, causal, minimum_phase, seed): ...@@ -125,7 +125,7 @@ def testDynamicModel(target, causal, minimum_phase, seed):
'minimum_phase': minimum_phase} 'minimum_phase': minimum_phase}
model, _ = ift.dynamic_operator(**dct) model, _ = ift.dynamic_operator(**dct)
pos = ift.from_random(model.domain, 'normal') pos = ift.from_random(model.domain, 'normal')
ift.extra.check_operator(model, pos, tol=1e-7, ntries=ntries) ift.extra.check_operator(model, pos, ntries=ntries)
if len(target.shape) > 1: if len(target.shape) > 1:
dct = { dct = {
'target': target, 'target': target,
...@@ -144,7 +144,7 @@ def testDynamicModel(target, causal, minimum_phase, seed): ...@@ -144,7 +144,7 @@ def testDynamicModel(target, causal, minimum_phase, seed):
dct['quant'] = 5 dct['quant'] = 5
model, _ = ift.dynamic_lightcone_operator(**dct) model, _ = ift.dynamic_lightcone_operator(**dct)
pos = ift.from_random(model.domain, 'normal') pos = ift.from_random(model.domain, 'normal')
ift.extra.check_operator(model, pos, tol=1e-7, ntries=ntries) ift.extra.check_operator(model, pos, ntries=ntries)
@pmp('h_space', _h_spaces) @pmp('h_space', _h_spaces)
......
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