Commit 4d8c1460 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'speedup_tests' into 'NIFTy_6'

Speedup tests

See merge request !471
parents 63a83795 236ebfb8
Pipeline #75164 passed with stages
in 8 minutes and 31 seconds
......@@ -11,20 +11,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
# Copyright(C) 2013-2020 Max-Planck-Society
# Authors: Gordian Edenhofer, Philipp Frank
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
import string
import numpy as np
from ..domain_tuple import DomainTuple
from ..linearization import Linearization
from ..field import Field
from ..linearization import Linearization
from ..multi_domain import MultiDomain
from ..multi_field import MultiField
from .operator import Operator
from .linear_operator import LinearOperator
from .operator import Operator
class MultiLinearEinsum(Operator):
......@@ -251,7 +253,6 @@ class LinearEinsum(LinearOperator):
path = np.einsum_path(numpy_subscripts, *plc, optimize=optimize)[0]
self._init_wo_preproc(mf, numpy_subscripts, _key_order, path, _target)
def _init_wo_preproc(self, mf, subscripts, keyorder, optimize, target):
self._ein_kw = {"optimize": optimize}
self._mf = mf
......
......@@ -19,28 +19,15 @@ import numpy as np
import pytest
import nifty6 as ift
from itertools import product
from .common import setup_function, teardown_function
# Currently it is not possible to parametrize fixtures. But this will
# hopefully be fixed in the future.
# https://docs.pytest.org/en/latest/proposals/parametrize_with_fixtures.html
SPACES = [ift.GLSpace(15),
ift.RGSpace(64, distances=.789),
ift.RGSpace([32, 32], distances=.789)]
for sp in SPACES[:3]:
SPACES.append(ift.MultiDomain.make({'asdf': sp}))
SEEDS = [4, 78, 23]
PARAMS = product(SEEDS, SPACES)
pmp = pytest.mark.parametrize
from .common import list2fixture, setup_function, teardown_function
@pytest.fixture(params=PARAMS)
def field(request):
with ift.random.Context(request.param[0]):
S = ift.ScalingOperator(request.param[1], 1.)
return S.draw_sample_with_dtype(dtype=np.float64)
spaces = [ift.GLSpace(5),
ift.MultiDomain.make({'': ift.RGSpace(5, distances=.789)}),
(ift.RGSpace(3, distances=.789), ift.UnstructuredDomain(2))]
pmp = pytest.mark.parametrize
field = list2fixture([ift.from_random('normal', sp) for sp in spaces])
ntries = 10
def test_gaussian(field):
......@@ -77,7 +64,7 @@ def test_studentt(field):
ift.extra.check_jacobian_consistency(energy, field, tol=1e-6)
theta = ift.from_random('normal',field.domain).exp()
energy = ift.StudentTEnergy(domain=field.domain, theta=theta)
ift.extra.check_jacobian_consistency(energy, field, tol=1e-6)
ift.extra.check_jacobian_consistency(energy, field, tol=1e-6, ntries=ntries)
def test_hamiltonian_and_KL(field):
......@@ -85,10 +72,10 @@ def test_hamiltonian_and_KL(field):
space = field.domain
lh = ift.GaussianEnergy(domain=space)
hamiltonian = ift.StandardHamiltonian(lh)
ift.extra.check_jacobian_consistency(hamiltonian, field)
samps = [ift.from_random('normal', space) for i in range(3)]
ift.extra.check_jacobian_consistency(hamiltonian, field, ntries=ntries)
samps = [ift.from_random('normal', space) for i in range(2)]
kl = ift.AveragedEnergy(hamiltonian, samps)
ift.extra.check_jacobian_consistency(kl, field)
ift.extra.check_jacobian_consistency(kl, field, ntries=ntries)
def test_variablecovariancegaussian(field):
......@@ -97,7 +84,7 @@ def test_variablecovariancegaussian(field):
dc = {'a': field, 'b': field.ptw("exp")}
mf = ift.MultiField.from_dict(dc)
energy = ift.VariableCovarianceGaussianEnergy(field.domain, 'a', 'b', np.float64)
ift.extra.check_jacobian_consistency(energy, mf, tol=1e-6)
ift.extra.check_jacobian_consistency(energy, mf, tol=1e-6, ntries=ntries)
energy(ift.Linearization.make_var(mf, want_metric=True)).metric.draw_sample()
......
......@@ -20,6 +20,7 @@ import pytest
from numpy.testing import assert_allclose, assert_equal, assert_raises
import nifty6 as ift
from .common import setup_function, teardown_function
pmp = pytest.mark.parametrize
......@@ -46,31 +47,26 @@ def _spec2(k):
return 42/(1. + k)**3
@pmp('space1', [
ift.RGSpace((8,), harmonic=True),
ift.RGSpace((8, 8), harmonic=True, distances=0.123)
])
@pmp('space1', [ift.RGSpace((8,), harmonic=True),
ift.RGSpace((8, 8), harmonic=True, distances=0.123)])
@pmp('space2', [ift.RGSpace((8,), harmonic=True), ift.LMSpace(12)])
def test_power_synthesize_analyze(space1, space2):
p1 = ift.PowerSpace(space1)
fp1 = ift.PS_field(p1, _spec1)
p2 = ift.PowerSpace(space2)
fp2 = ift.PS_field(p2, _spec2)
op1 = ift.create_power_operator((space1, space2), _spec1, 0)
op2 = ift.create_power_operator((space1, space2), _spec2, 1)
opfull = op2(op1)
opfull = op2 @ op1
samples = 500
samples = 120
sc1 = ift.StatCalculator()
sc2 = ift.StatCalculator()
for ii in range(samples):
sk = opfull.draw_sample_with_dtype(dtype=np.float64)
sp = ift.power_analyze(sk, spaces=(0, 1), keep_phase_information=False)
sc1.add(sp.sum(spaces=1)/fp2.s_sum())
sc2.add(sp.sum(spaces=0)/fp1.s_sum())
assert_allclose(sc1.mean.val, fp1.val, rtol=0.2)
assert_allclose(sc2.mean.val, fp2.val, rtol=0.2)
......
......@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
# Copyright(C) 2013-2020 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
......@@ -19,6 +19,7 @@ import numpy as np
import pytest
import nifty6 as ift
from .common import setup_function, teardown_function
......@@ -29,14 +30,12 @@ def _flat_PS(k):
pmp = pytest.mark.parametrize
@pmp('space', [
ift.GLSpace(15),
ift.RGSpace(64, distances=.789),
ift.RGSpace([32, 32], distances=.789)
])
@pmp('space', [ift.GLSpace(5),
ift.RGSpace(5, distances=.789),
ift.RGSpace([2, 2], distances=.789)])
@pmp('nonlinearity', ["tanh", "exp", ""])
@pmp('noise', [1, 1e-2, 1e2])
@pmp('seed', [4, 78, 23])
@pmp('seed', [4, 78])
def test_gaussian_energy(space, nonlinearity, noise, seed):
with ift.random.Context(seed):
dim = len(space.shape)
......
......@@ -193,7 +193,7 @@ def testGeometryRemover(sp, dtype):
@pmp('spaces', [0, 1, 2, 3, (0, 1), (0, 2), (0, 1, 2), (0, 2, 3), (1, 3)])
@pmp('wgt', [0, 1, 2, -1])
def testContractionOperator(spaces, wgt, dtype):
dom = (ift.RGSpace(10), ift.RGSpace(13), ift.GLSpace(5), ift.HPSpace(4))
dom = (ift.RGSpace(1), ift.RGSpace(2), ift.GLSpace(3), ift.HPSpace(2))
op = ift.ContractionOperator(dom, spaces, wgt)
ift.extra.consistency_check(op, dtype, dtype)
......@@ -210,8 +210,8 @@ def testDomainTupleFieldInserter():
@pmp('factor', [1, 2, 2.7])
@pmp('central', [False, True])
def testZeroPadder(space, factor, dtype, central):
dom = (ift.RGSpace(10), ift.UnstructuredDomain(13), ift.RGSpace(7, 12),
ift.HPSpace(4))
dom = (ift.RGSpace(4), ift.UnstructuredDomain(5), ift.RGSpace(3, 4),
ift.HPSpace(2))
newshape = [int(factor*l) for l in dom[space].shape]
op = ift.FieldZeroPadder(dom, newshape, space, central)
ift.extra.consistency_check(op, dtype, dtype)
......
......@@ -11,84 +11,81 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
# Copyright(C) 2013-2020 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import pytest
from numpy.testing import assert_allclose
from numpy.testing import assert_, assert_allclose
import nifty6 as ift
from ..common import setup_function, teardown_function
pmp = pytest.mark.parametrize
def _stats(op, samples):
sc = ift.StatCalculator()
for s in samples:
sc.add(op(s.extract(op.domain)))
return sc.mean.val, sc.var.ptw("sqrt").val
@pmp('sspace', [ift.RGSpace(4), ift.RGSpace((4, 4), (0.123, 0.4)),
ift.HPSpace(8), ift.GLSpace(4)])
@pmp('N', [0, 2])
def testAmplitudesInvariants(sspace, N):
fsspace = ift.RGSpace((12,), (0.4,))
dofdex1, dofdex2, dofdex3 = None, None, None
if N == 2:
dofdex1, dofdex2, dofdex3 = [0, 0], [1, 0], [1, 1]
astds = 0.2, 1.2
offset_std_mean = 1.3
fa = ift.CorrelatedFieldMaker.make(1.2, offset_std_mean, 1e-2, '', N,
dofdex1)
fa.add_fluctuations(sspace, astds[0], 1e-2, 1.1, 2., 2.1, .5, -2, 1.,
'spatial', dofdex=dofdex2)
fa.add_fluctuations(fsspace, astds[1], 1e-2, 3.1, 1., .5, .1, -4, 1.,
'freq', dofdex=dofdex3)
op = fa.finalize()
samples = [ift.from_random('normal', op.domain) for _ in range(100)]
tot_flm, _ = _stats(fa.total_fluctuation, samples)
offset_amp_std, _ = _stats(fa.amplitude_total_offset, samples)
intergated_fluct_std0, _ = _stats(fa.average_fluctuation(0), samples)
intergated_fluct_std1, _ = _stats(fa.average_fluctuation(1), samples)
slice_fluct_std0, _ = _stats(fa.slice_fluctuation(0), samples)
slice_fluct_std1, _ = _stats(fa.slice_fluctuation(1), samples)
sams = [op(s) for s in samples]
fluct_total = fa.total_fluctuation_realized(sams)
fluct_space = fa.average_fluctuation_realized(sams, 0)
fluct_freq = fa.average_fluctuation_realized(sams, 1)
zm_std_mean = fa.offset_amplitude_realized(sams)
sl_fluct_space = fa.slice_fluctuation_realized(sams, 0)
sl_fluct_freq = fa.slice_fluctuation_realized(sams, 1)
assert_allclose(offset_amp_std, zm_std_mean, rtol=0.5)
assert_allclose(intergated_fluct_std0, fluct_space, rtol=0.5)
assert_allclose(intergated_fluct_std1, fluct_freq, rtol=0.5)
assert_allclose(tot_flm, fluct_total, rtol=0.5)
assert_allclose(slice_fluct_std0, sl_fluct_space, 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.add_fluctuations(fsspace, astds[1], 1., 3.1, 1., .5, .1, -4, 1., 'freq',
dofdex=dofdex3)
m = 3.
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)
op = fa.finalize()
em, estd = _stats(fa.slice_fluctuation(0), samples)
@pytest.mark.parametrize('sspace', [ift.RGSpace(4),
ift.RGSpace((4, 4), (0.123, 0.4)),
ift.HPSpace(8),
ift.GLSpace(4)])
@pytest.mark.parametrize('rseed', [13, 2])
@pytest.mark.parametrize('Astds', [[1., 3.], [0.2, 1.4]])
@pytest.mark.parametrize('offset_std_mean', [1., 10.])
@pytest.mark.parametrize('N', [0, 2])
@pytest.mark.parametrize('zm_mean', [0, 1.])
def testAmplitudesConsistency(rseed, sspace, Astds, offset_std_mean, N, zm_mean):
def stats(op, samples):
sc = ift.StatCalculator()
for s in samples:
sc.add(op(s.extract(op.domain)))
return sc.mean.val, sc.var.ptw("sqrt").val
with ift.random.Context(rseed):
nsam = 100
fsspace = ift.RGSpace((12,), (0.4,))
if N==2:
dofdex1 = [0,0]
dofdex2 = [1,0]
dofdex3 = [1,1]
else:
dofdex1, dofdex2, dofdex3 = None, None, None
fa = ift.CorrelatedFieldMaker.make(zm_mean, offset_std_mean, 1E-8, '', N, dofdex1)
fa.add_fluctuations(sspace, Astds[0], 1E-8, 1.1, 2., 2.1, .5, -2, 1.,
'spatial', dofdex = dofdex2)
fa.add_fluctuations(fsspace, Astds[1], 1E-8, 3.1, 1., .5, .1, -4, 1.,
'freq', dofdex = dofdex3)
op = fa.finalize()
samples = [ift.from_random('normal', op.domain) for _ in range(nsam)]
tot_flm, _ = stats(fa.total_fluctuation, samples)
offset_amp_std, _ = stats(fa.amplitude_total_offset, samples)
intergated_fluct_std0, _ = stats(fa.average_fluctuation(0), samples)
intergated_fluct_std1, _ = stats(fa.average_fluctuation(1), samples)
slice_fluct_std0, _ = stats(fa.slice_fluctuation(0), samples)
slice_fluct_std1, _ = stats(fa.slice_fluctuation(1), samples)
sams = [op(s) for s in samples]
fluct_total = fa.total_fluctuation_realized(sams)
fluct_space = fa.average_fluctuation_realized(sams, 0)
fluct_freq = fa.average_fluctuation_realized(sams, 1)
zm_std_mean = fa.offset_amplitude_realized(sams)
sl_fluct_space = fa.slice_fluctuation_realized(sams, 0)
sl_fluct_freq = fa.slice_fluctuation_realized(sams, 1)
assert_allclose(offset_amp_std, zm_std_mean, rtol=0.5)
assert_allclose(intergated_fluct_std0, fluct_space, rtol=0.5)
assert_allclose(intergated_fluct_std1, fluct_freq, rtol=0.5)
assert_allclose(tot_flm, fluct_total, rtol=0.5)
assert_allclose(slice_fluct_std0, sl_fluct_space, 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.add_fluctuations(fsspace, Astds[1], 1., 3.1, 1., .5, .1, -4, 1., 'freq', dofdex = dofdex3)
m = 3.
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)
op = fa.finalize()
em, estd = stats(fa.slice_fluctuation(0), samples)
assert_allclose(m, em, rtol=0.5)
assert op.target[-2] == sspace
assert op.target[-1] == fsspace
assert_allclose(m, em, rtol=0.5)
assert_(op.target[-2] == sspace)
assert_(op.target[-1] == fsspace)
......@@ -11,21 +11,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
# Copyright(C) 2013-2020 Max-Planck-Society
# Authors: Gordian Edenhofer, Philipp Frank
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import pytest
from numpy.testing import assert_allclose
import numpy as np
from nifty6.extra import check_jacobian_consistency, consistency_check
from numpy.testing import assert_, assert_allclose
import nifty6 as ift
from nifty6.extra import check_jacobian_consistency, consistency_check
from ..common import list2fixture, setup_function, teardown_function
spaces = (ift.UnstructuredDomain(4),
ift.RGSpace((3,2)),
ift.RGSpace((3, 2)),
ift.LMSpace(5),
ift.GLSpace(4))
......@@ -35,26 +35,18 @@ dtype = list2fixture([np.float64, np.complex128])
def test_linear_einsum_outer(space1, space2, dtype, n_invocations=10):
mf_dom = ift.MultiDomain.make(
{
"dom01": space1,
"dom02":
ift.DomainTuple.make(
(space1, space2)
)
}
)
mf_dom = ift.MultiDomain.make({
"dom01": space1,
"dom02": ift.DomainTuple.make((space1, space2))})
mf = ift.from_random("normal", mf_dom, dtype=dtype)
ss = "i,ij,j->ij"
key_order = ("dom01", "dom02")
le = ift.LinearEinsum(space2, mf, ss, key_order=key_order)
assert consistency_check(le, domain_dtype=dtype,target_dtype=dtype) is None
assert_(consistency_check(le, domain_dtype=dtype, target_dtype=dtype) is None)
le_ift = ift.DiagonalOperator(
mf["dom01"], domain=mf_dom["dom02"], spaces=0
) @ ift.DiagonalOperator(mf["dom02"]) @ ift.OuterProduct(
ift.full(mf_dom["dom01"], 1.), ift.DomainTuple.make(mf_dom["dom02"][1])
)
le_ift = ift.DiagonalOperator(mf["dom01"], domain=mf_dom["dom02"], spaces=0) @ ift.DiagonalOperator(mf["dom02"])
le_ift = le_ift @ ift.OuterProduct(ift.full(mf_dom["dom01"], 1.),
ift.DomainTuple.make(mf_dom["dom02"][1]))
for _ in range(n_invocations):
r = ift.from_random("normal", le.domain, dtype=dtype)
......@@ -64,26 +56,20 @@ def test_linear_einsum_outer(space1, space2, dtype, n_invocations=10):
def test_linear_einsum_contraction(space1, space2, dtype, n_invocations=10):
mf_dom = ift.MultiDomain.make(
{
"dom01": space1,
"dom02":
ift.DomainTuple.make(
(space1, space2)
)
}
)
mf_dom = ift.MultiDomain.make({
"dom01": space1,
"dom02": ift.DomainTuple.make((space1, space2))})
mf = ift.from_random("normal", mf_dom, dtype=dtype)
ss = "i,ij,j->i"
key_order = ("dom01", "dom02")
le = ift.LinearEinsum(space2, mf, ss, key_order=key_order)
assert consistency_check(le, domain_dtype=dtype,target_dtype=dtype) is None
assert_(consistency_check(le, domain_dtype=dtype, target_dtype=dtype) is None)
le_ift = ift.ContractionOperator(mf_dom["dom02"], 1) @ ift.DiagonalOperator(
mf["dom01"], domain=mf_dom["dom02"], spaces=0
) @ ift.DiagonalOperator(mf["dom02"]) @ ift.OuterProduct(
ift.full(mf_dom["dom01"], 1.), ift.DomainTuple.make(mf_dom["dom02"][1])
)
le_ift = ift.ContractionOperator(mf_dom["dom02"], 1)
le_ift = le_ift @ ift.DiagonalOperator(mf["dom01"], domain=mf_dom["dom02"], spaces=0)
le_ift = le_ift @ ift.DiagonalOperator(mf["dom02"])
le_ift = le_ift @ ift.OuterProduct(ift.full(mf_dom["dom01"], 1.),
ift.DomainTuple.make(mf_dom["dom02"][1]))
for _ in range(n_invocations):
r = ift.from_random("normal", le.domain, dtype=dtype)
......@@ -103,7 +89,7 @@ class _SwitchSpacesOperator(ift.LinearOperator):
n_spaces = len(self._domain)
if space1 >= n_spaces or space1 < 0 \
or space2 >= n_spaces or space2 < 0:
or space2 >= n_spaces or space2 < 0:
raise ValueError("invalid space value")
tgt = list(self._domain)
......@@ -119,33 +105,23 @@ class _SwitchSpacesOperator(ift.LinearOperator):
def apply(self, x, mode):
self._check_input(x, mode)
if mode == self.TIMES:
val = np.moveaxis(x.val, self._axes_dom, self._axes_tgt)
dom = self._target
else:
val = np.moveaxis(x.val, self._axes_tgt, self._axes_dom)
dom = self._domain
return ift.Field(dom, val)
def test_multi_linear_einsum_outer(
space1, space2, dtype, n_invocations=10, ntries=100
):
mf_dom = ift.MultiDomain.make(
{
"dom01": space1,
"dom02":ift.DomainTuple.make((space1, space2)),
"dom03": space2
}
)
args = self._axes_dom, self._axes_tgt
if mode == self.ADJOINT_TIMES:
args = args[::-1]
return ift.Field(self._tgt(mode), np.moveaxis(x.val, *args))
def test_multi_linear_einsum_outer(space1, space2, dtype):
ntries = 10
n_invocations = 5
mf_dom = ift.MultiDomain.make({
"dom01": space1,
"dom02": ift.DomainTuple.make((space1, space2)),
"dom03": space2})
ss = "i,ij,j->ij"
key_order = ("dom01", "dom02", "dom03")
mle = ift.MultiLinearEinsum(mf_dom, ss, key_order=key_order)
check_jacobian_consistency(
mle, ift.from_random("normal", mle.domain, dtype=dtype), ntries=ntries
)
check_jacobian_consistency(mle, ift.from_random("normal", mle.domain, dtype=dtype), ntries=ntries)
outer_i = ift.OuterProduct(
ift.full(mf_dom["dom03"], 1.), ift.DomainTuple.make(mf_dom["dom02"][0])
......@@ -154,15 +130,13 @@ def test_multi_linear_einsum_outer(
ift.full(mf_dom["dom01"], 1.), ift.DomainTuple.make(mf_dom["dom02"][1])
)
# SwitchSpacesOperator is equivalent to LinearEinsum with "ij->ji"
mle_ift = _SwitchSpacesOperator(
outer_i.target, 1
) @ outer_i @ ift.FieldAdapter(mf_dom["dom01"], "dom01") * ift.FieldAdapter(
mf_dom["dom02"], "dom02"
) * (outer_j @ ift.FieldAdapter(mf_dom["dom03"], "dom03"))
mle_ift = _SwitchSpacesOperator(outer_i.target, 1) @ outer_i @ \
ift.FieldAdapter(mf_dom["dom01"], "dom01") * \
ift.FieldAdapter(mf_dom["dom02"], "dom02") * \
(outer_j @ ift.FieldAdapter(mf_dom["dom03"], "dom03"))
for _ in range(n_invocations):
rl = ift.Linearization.make_var(
ift.from_random("normal", mle.domain, dtype=dtype))
rl = ift.Linearization.make_var(ift.from_random("normal", mle.domain, dtype=dtype))
mle_rl, mle_ift_rl = mle(rl), mle_ift(rl)
assert_allclose(mle_rl.val.val, mle_ift_rl.val.val)
assert_allclose(mle_rl.jac(rl.val).val, mle_ift_rl.jac(rl.val).val)
......
......@@ -11,11 +11,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
# Copyright(C) 2013-2020 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
import pytest
import nifty6 as ift
......@@ -24,17 +23,18 @@ from ..common import list2fixture, setup_function, teardown_function
pmp = pytest.mark.parametrize
space = list2fixture([
ift.GLSpace(15),
ift.RGSpace(64, distances=.789),
ift.RGSpace([32, 32], distances=.789)
ift.GLSpace(5),
ift.RGSpace(3, distances=.789),
ift.RGSpace([4, 4], distances=.789)
])
_h_RG_spaces = [
ift.RGSpace(7, distances=0.2, harmonic=True),
ift.RGSpace((12, 46), distances=(.2, .3), harmonic=True)
ift.RGSpace((3, 4), distances=(.2, .3), harmonic=True)
]
_h_spaces = _h_RG_spaces + [ift.LMSpace(17)]
space1 = space
seed = list2fixture([4, 78, 23])
seed = list2fixture([4, 78])
ntries = 10
def testBasics(space, seed):
......@@ -42,7 +42,7 @@ def testBasics(space, seed):
s = ift.from_random('normal', space)
var = ift.Linearization.make_var(s)
model = ift.ScalingOperator(var.target, 6.)
ift.extra.check_jacobian_consistency(model, var.val)
ift.extra.check_jacobian_consistency(model, var.val, ntries=ntries)
@pmp('type1', ['Variable', 'Constant'])
......@@ -56,36 +56,36 @@ def testBinary(type1, type2, space, seed):
select_s2 = ift.ducktape(None, dom2, "s2")
model = select_s1*select_s2
pos = ift.from_random("normal", dom)
ift.extra.check_jacobian_consistency(model, pos, ntries=20)
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)