Commit f7b12e3b authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'streamlining' into 'NIFTy_6'

Resolve "Streamline arguments position"

See merge request !474
parents 9abb8a34 1af9ab0f
Pipeline #75223 failed with stages
in 3 minutes and 16 seconds
......@@ -26,7 +26,7 @@ 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])
field = list2fixture([ift.from_random(sp, 'normal') for sp in spaces])
ntries = 10
......@@ -62,7 +62,7 @@ def test_studentt(field):
return
energy = ift.StudentTEnergy(domain=field.domain, theta=.5)
ift.extra.check_jacobian_consistency(energy, field, tol=1e-6)
theta = ift.from_random('normal',field.domain).exp()
theta = ift.from_random(field.domain, 'normal').exp()
energy = ift.StudentTEnergy(domain=field.domain, theta=theta)
ift.extra.check_jacobian_consistency(energy, field, tol=1e-6, ntries=ntries)
......@@ -73,7 +73,7 @@ def test_hamiltonian_and_KL(field):
lh = ift.GaussianEnergy(domain=space)
hamiltonian = ift.StandardHamiltonian(lh)
ift.extra.check_jacobian_consistency(hamiltonian, field, ntries=ntries)
samps = [ift.from_random('normal', space) for i in range(2)]
samps = [ift.from_random(space, 'normal') for i in range(2)]
kl = ift.AveragedEnergy(hamiltonian, samps)
ift.extra.check_jacobian_consistency(kl, field, ntries=ntries)
......
......@@ -104,7 +104,7 @@ def test_DiagonalOperator_power_analyze2(space1, space2):
ift.RGSpace((2, 3, 7))
])
def test_norm(space):
f = ift.Field.from_random("normal", domain=space, dtype=np.complex128)
f = ift.Field.from_random(domain=space, random_type="normal", dtype=np.complex128)
gd = f.val.reshape(-1)
assert_allclose(f.norm(), np.linalg.norm(gd))
assert_allclose(f.norm(1), np.linalg.norm(gd, ord=1))
......@@ -115,8 +115,8 @@ def test_norm(space):
def test_vdot():
s = ift.RGSpace((10,))
f1 = ift.Field.from_random("normal", domain=s, dtype=np.complex128)
f2 = ift.Field.from_random("normal", domain=s, dtype=np.complex128)
f1 = ift.Field.from_random(domain=s, random_type="normal", dtype=np.complex128)
f2 = ift.Field.from_random(domain=s, random_type="normal", dtype=np.complex128)
assert_allclose(f1.s_vdot(f2), f1.vdot(f2, spaces=0).val)
assert_allclose(f1.s_vdot(f2), np.conj(f2.s_vdot(f1)))
......@@ -298,8 +298,8 @@ def test_stdfunc():
fx = ift.full(f.domain, 67.)
assert_equal(f.shape, fx.shape)
assert_equal(fx.val, 67.)
f = ift.Field.from_random("normal", s)
f2 = ift.Field.from_random("normal", s)
f = ift.Field.from_random(s, "normal")
f2 = ift.Field.from_random(s, "normal")
assert_equal((f > f2).val, f.val > f2.val)
assert_equal((f >= f2).val, f.val >= f2.val)
assert_equal((f < f2).val, f.val < f2.val)
......@@ -342,7 +342,7 @@ def test_funcs(num, dom, func):
@pmp('dtype', [np.float64, np.complex128])
def test_from_random(rtype, dtype):
sp = ift.RGSpace(3)
ift.Field.from_random(rtype, sp, dtype=dtype)
ift.Field.from_random(sp, rtype, dtype=dtype)
def test_field_of_objects():
......
......@@ -41,7 +41,7 @@ def test_kl(constants, point_estimates, mirror_samples, mf):
ic = ift.GradientNormController(iteration_limit=5)
ic.enable_logging()
h = ift.StandardHamiltonian(lh, ic_samp=ic)
mean0 = ift.from_random('normal', h.domain)
mean0 = ift.from_random(h.domain, 'normal')
nsamps = 2
kl = ift.MetricGaussianKL(mean0,
......
......@@ -52,8 +52,8 @@ slow_minimizers = ['ift.SteepestDescent(IC)']
slow_minimizers)
@pmp('space', spaces)
def test_quadratic_minimization(minimizer, space):
starting_point = ift.Field.from_random('normal', domain=space)*10
covariance_diagonal = ift.Field.from_random('uniform', domain=space) + 0.5
starting_point = ift.Field.from_random(domain=space, random_type='normal') * 10
covariance_diagonal = ift.Field.from_random(domain=space, random_type='uniform') + 0.5
covariance = ift.DiagonalOperator(covariance_diagonal)
required_result = ift.full(space, 1.)
......@@ -78,11 +78,11 @@ def test_quadratic_minimization(minimizer, space):
def test_WF_curvature(space):
required_result = ift.full(space, 1.)
s = ift.Field.from_random('uniform', domain=space) + 0.5
s = ift.Field.from_random(domain=space, random_type='uniform') + 0.5
S = ift.DiagonalOperator(s)
r = ift.Field.from_random('uniform', domain=space)
r = ift.Field.from_random(domain=space, random_type='uniform')
R = ift.DiagonalOperator(r)
n = ift.Field.from_random('uniform', domain=space) + 0.5
n = ift.Field.from_random(domain=space, random_type='uniform') + 0.5
N = ift.DiagonalOperator(n)
all_diag = 1./s + r**2/n
curv = ift.WienerFilterCurvature(R, N, S, iteration_controller=IC,
......@@ -100,7 +100,7 @@ def test_WF_curvature(space):
if len(space.shape) == 1:
R = ift.ValueInserter(space, [0])
n = ift.from_random('uniform', R.domain) + 0.5
n = ift.from_random(R.domain, 'uniform') + 0.5
N = ift.DiagonalOperator(n)
all_diag = 1./s + R(1/n)
curv = ift.WienerFilterCurvature(R.adjoint, N, S,
......@@ -125,7 +125,7 @@ def test_rosenbrock(minimizer):
except ImportError:
raise SkipTest
space = ift.DomainTuple.make(ift.UnstructuredDomain((2,)))
starting_point = ift.Field.from_random('normal', domain=space)*10
starting_point = ift.Field.from_random(domain=space, random_type='normal') * 10
class RBEnergy(ift.Energy):
def __init__(self, position):
......
......@@ -50,7 +50,7 @@ def test_kl(constants, point_estimates, mirror_samples, mode, mf):
lh = ift.GaussianEnergy(domain=op.target, sampling_dtype=np.float64) @ op
ic = ift.GradientNormController(iteration_limit=5)
h = ift.StandardHamiltonian(lh, ic_samp=ic)
mean0 = ift.from_random('normal', h.domain)
mean0 = ift.from_random(h.domain, 'normal')
nsamps = 2
args = {'constants': constants,
'point_estimates': point_estimates,
......
......@@ -25,13 +25,13 @@ dom = ift.makeDomain({"d1": ift.RGSpace(10)})
def test_vdot():
f1 = ift.from_random("normal", domain=dom, dtype=np.complex128)
f2 = ift.from_random("normal", domain=dom, dtype=np.complex128)
f1 = ift.from_random(domain=dom, random_type="normal", dtype=np.complex128)
f2 = ift.from_random(domain=dom, random_type="normal", dtype=np.complex128)
assert_allclose(f1.s_vdot(f2), np.conj(f2.s_vdot(f1)))
def test_func():
f1 = ift.from_random("normal", domain=dom, dtype=np.complex128)
f1 = ift.from_random(domain=dom, random_type="normal", dtype=np.complex128)
assert_allclose(
f1.ptw("exp").ptw("log")["d1"].val, f1["d1"].val)
......
......@@ -54,8 +54,8 @@ def testLOSResponse(sp, dtype):
@pmp('sp', _h_spaces + _p_spaces + _pow_spaces)
def testOperatorCombinations(sp, dtype):
a = ift.DiagonalOperator(ift.Field.from_random("normal", sp, dtype=dtype))
b = ift.DiagonalOperator(ift.Field.from_random("normal", sp, dtype=dtype))
a = ift.DiagonalOperator(ift.Field.from_random(sp, "normal", dtype=dtype))
b = ift.DiagonalOperator(ift.Field.from_random(sp, "normal", dtype=dtype))
op = ift.SandwichOperator.make(a, b)
ift.extra.consistency_check(op, dtype, dtype)
op = a(b)
......@@ -91,7 +91,7 @@ def testConjugationOperator(sp):
@pmp('sp', _h_spaces + _p_spaces + _pow_spaces)
def testOperatorAdaptor(sp, dtype):
op = ift.DiagonalOperator(ift.Field.from_random("normal", sp, dtype=dtype))
op = ift.DiagonalOperator(ift.Field.from_random(sp, "normal", dtype=dtype))
ift.extra.consistency_check(op.adjoint, dtype, dtype)
ift.extra.consistency_check(op.inverse, dtype, dtype)
ift.extra.consistency_check(op.inverse.adjoint, dtype, dtype)
......@@ -169,7 +169,7 @@ def testHarmonic(sp, dtype):
@pmp('sp', _p_spaces)
def testMask(sp, dtype):
# Create mask
f = ift.from_random('normal', sp).val
f = ift.from_random(sp, 'normal').val
mask = np.zeros_like(f)
mask[f > 0] = 1
mask = ift.Field.from_raw(sp, mask)
......@@ -180,7 +180,7 @@ def testMask(sp, dtype):
@pmp('sp', _h_spaces + _p_spaces)
def testDiagonal(sp, dtype):
op = ift.DiagonalOperator(ift.Field.from_random("normal", sp, dtype=dtype))
op = ift.DiagonalOperator(ift.Field.from_random(sp, "normal", dtype=dtype))
ift.extra.consistency_check(op, dtype, dtype)
......@@ -240,8 +240,8 @@ def testRegridding(args):
ift.DomainTuple.make(ift.RGSpace((10, 12), distances=(0.1, 1.)),)
])
def testOuter(fdomain, domain):
f = ift.from_random('normal', fdomain)
op = ift.OuterProduct(f, domain)
f = ift.from_random(fdomain, 'normal')
op = ift.OuterProduct(domain, f)
ift.extra.consistency_check(op)
......
......@@ -33,15 +33,15 @@ space2 = space1
def test_times_adjoint_times(space1, space2):
cspace = (space1, space2)
diag1 = ift.Field.from_random('normal', domain=space1)
diag2 = ift.Field.from_random('normal', domain=space2)
diag1 = ift.Field.from_random(domain=space1, random_type='normal')
diag2 = ift.Field.from_random(domain=space2, random_type='normal')
op1 = ift.DiagonalOperator(diag1, cspace, spaces=(0,))
op2 = ift.DiagonalOperator(diag2, cspace, spaces=(1,))
op = op2(op1)
rand1 = ift.Field.from_random('normal', domain=(space1, space2))
rand2 = ift.Field.from_random('normal', domain=(space1, space2))
rand1 = ift.Field.from_random(domain=(space1, space2), random_type='normal')
rand2 = ift.Field.from_random(domain=(space1, space2), random_type='normal')
tt1 = rand2.s_vdot(op.times(rand1))
tt2 = rand1.s_vdot(op.adjoint_times(rand2))
......@@ -50,14 +50,14 @@ def test_times_adjoint_times(space1, space2):
def test_times_inverse_times(space1, space2):
cspace = (space1, space2)
diag1 = ift.Field.from_random('normal', domain=space1)
diag2 = ift.Field.from_random('normal', domain=space2)
diag1 = ift.Field.from_random(domain=space1, random_type='normal')
diag2 = ift.Field.from_random(domain=space2, random_type='normal')
op1 = ift.DiagonalOperator(diag1, cspace, spaces=(0,))
op2 = ift.DiagonalOperator(diag2, cspace, spaces=(1,))
op = op2(op1)
rand1 = ift.Field.from_random('normal', domain=(space1, space2))
rand1 = ift.Field.from_random(domain=(space1, space2), random_type='normal')
tt1 = op.inverse_times(op.times(rand1))
assert_allclose(tt1.val, rand1.val)
......
......@@ -30,7 +30,7 @@ space = list2fixture([
def test_const_func(space):
sig = ift.Field.from_random('normal', domain=space)
sig = ift.Field.from_random(domain=space, random_type='normal')
fco_op = ift.FuncConvolutionOperator(space, lambda x: np.ones(x.shape))
vals = fco_op(sig).val
vals = np.round(vals, decimals=5)
......@@ -46,7 +46,7 @@ def test_gaussian_smoothing():
N = 128
sigma = N / 10**4
dom = ift.RGSpace(N)
sig = ift.Field.from_random('normal', dom).ptw("exp")
sig = ift.Field.from_random(dom, 'normal').ptw("exp")
fco_op = ift.FuncConvolutionOperator(dom, lambda x: gauss(x, sigma))
sm_op = ift.HarmonicSmoothingOperator(dom, sigma)
assert_allclose(fco_op(sig).val,
......
......@@ -52,7 +52,7 @@ def testAmplitudesInvariants(sspace, N):
'freq', dofdex=dofdex3)
op = fa.finalize()
samples = [ift.from_random('normal', op.domain) for _ in range(100)]
samples = [ift.from_random(op.domain, 'normal') 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)
......
......@@ -31,16 +31,16 @@ space = list2fixture([
def test_property(space):
diag = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
if D.domain[0] != space:
raise TypeError
def test_times_adjoint(space):
rand1 = ift.Field.from_random('normal', domain=space)
rand2 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
rand2 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt1 = rand1.s_vdot(D.times(rand2))
tt2 = rand2.s_vdot(D.times(rand1))
......@@ -48,47 +48,47 @@ def test_times_adjoint(space):
def test_times_inverse(space):
rand1 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt1 = D.times(D.inverse_times(rand1))
assert_allclose(rand1.val, tt1.val)
def test_times(space):
rand1 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt = D.times(rand1)
assert_equal(tt.domain[0], space)
def test_adjoint_times(space):
rand1 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt = D.adjoint_times(rand1)
assert_equal(tt.domain[0], space)
def test_inverse_times(space):
rand1 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt = D.inverse_times(rand1)
assert_equal(tt.domain[0], space)
def test_adjoint_inverse_times(space):
rand1 = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random('normal', domain=space)
rand1 = ift.Field.from_random(domain=space, random_type='normal')
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
tt = D.adjoint_inverse_times(rand1)
assert_equal(tt.domain[0], space)
def test_diagonal(space):
diag = ift.Field.from_random('normal', domain=space)
diag = ift.Field.from_random(domain=space, random_type='normal')
D = ift.DiagonalOperator(diag)
diag_op = D(ift.Field.full(space, 1.))
assert_allclose(diag.val, diag_op.val)
......@@ -38,20 +38,20 @@ 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 = ift.from_random("normal", mf_dom, dtype=dtype)
mf = ift.from_random(mf_dom, "normal", 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)
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]))
le_ift = le_ift @ ift.OuterProduct(ift.DomainTuple.make(mf_dom["dom02"][1]),
ift.full(mf_dom["dom01"], 1.))
for _ in range(n_invocations):
r = ift.from_random("normal", le.domain, dtype=dtype)
r = ift.from_random(le.domain, "normal", dtype=dtype)
assert_allclose(le(r).val, le_ift(r).val)
r_adj = ift.from_random("normal", le.target, dtype=dtype)
r_adj = ift.from_random(le.target, "normal", dtype=dtype)
assert_allclose(le.adjoint(r_adj).val, le_ift.adjoint(r_adj).val)
......@@ -59,7 +59,7 @@ 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 = ift.from_random("normal", mf_dom, dtype=dtype)
mf = ift.from_random(mf_dom, "normal", dtype=dtype)
ss = "i,ij,j->i"
key_order = ("dom01", "dom02")
le = ift.LinearEinsum(space2, mf, ss, key_order=key_order)
......@@ -68,13 +68,13 @@ def test_linear_einsum_contraction(space1, space2, dtype, n_invocations=10):
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]))
le_ift = le_ift @ ift.OuterProduct(ift.DomainTuple.make(mf_dom["dom02"][1]),
ift.full(mf_dom["dom01"], 1.),)
for _ in range(n_invocations):
r = ift.from_random("normal", le.domain, dtype=dtype)
r = ift.from_random(le.domain, "normal", dtype=dtype)
assert_allclose(le(r).val, le_ift(r).val)
r_adj = ift.from_random("normal", le.target, dtype=dtype)
r_adj = ift.from_random(le.target, "normal", dtype=dtype)
assert_allclose(le.adjoint(r_adj).val, le_ift.adjoint(r_adj).val)
......@@ -121,13 +121,13 @@ def test_multi_linear_einsum_outer(space1, space2, dtype):
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(mle.domain, "normal", dtype=dtype), ntries=ntries)
outer_i = ift.OuterProduct(
ift.full(mf_dom["dom03"], 1.), ift.DomainTuple.make(mf_dom["dom02"][0])
ift.DomainTuple.make(mf_dom["dom02"][0]), ift.full(mf_dom["dom03"], 1.)
)
outer_j = ift.OuterProduct(
ift.full(mf_dom["dom01"], 1.), ift.DomainTuple.make(mf_dom["dom02"][1])
ift.DomainTuple.make(mf_dom["dom02"][1]), ift.full(mf_dom["dom01"], 1.)
)
# SwitchSpacesOperator is equivalent to LinearEinsum with "ij->ji"
mle_ift = _SwitchSpacesOperator(outer_i.target, 1) @ outer_i @ \
......@@ -136,12 +136,12 @@ def test_multi_linear_einsum_outer(space1, space2, dtype):
(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(mle.domain, "normal", 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)
rj_adj = ift.from_random("normal", mle_rl.jac.target, dtype=dtype)
rj_adj = ift.from_random(mle_rl.jac.target, "normal", dtype=dtype)
mle_j_val = mle_rl.jac.adjoint(rj_adj).val
mle_ift_j_val = mle_ift_rl.jac.adjoint(rj_adj).val
for k in mle_ift.domain.keys():
......
......@@ -44,16 +44,14 @@ def test_fft1D(d, dtype, op):
b = ift.RGSpace(dim1, distances=1./(dim1*d), harmonic=True)
fft = op(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=7, mean=3, dtype=dtype)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=dtype, std=7, mean=3)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
a, b = b, a
fft = ift.FFTOperator(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=7, mean=3, dtype=dtype)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=dtype, std=7, mean=3)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
......@@ -72,16 +70,14 @@ def test_fft2D(dim1, dim2, d1, d2, dtype, op, nthreads):
[dim1, dim2], distances=[1./(dim1*d1), 1./(dim2*d2)], harmonic=True)
fft = op(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=7, mean=3, dtype=dtype)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=dtype, std=7, mean=3)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
a, b = b, a
fft = ift.FFTOperator(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=7, mean=3, dtype=dtype)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=dtype, std=7, mean=3)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
ift.fft.set_nthreads(1)
......@@ -96,8 +92,7 @@ def test_composed_fft(index, dtype, op):
ift.RGSpace((5, 6))]
fft = op(domain=a, space=index)
inp = ift.Field.from_random(
domain=(a1, a2, a3), random_type='normal', std=7, mean=3, dtype=dtype)
inp = ift.Field.from_random(domain=(a1, a2, a3), random_type='normal', dtype=dtype, std=7, mean=3)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
......@@ -111,8 +106,7 @@ def test_normalisation(space, dtype, op):
tol = 10*_get_rtol(dtype)
cospace = space.get_default_codomain()
fft = op(space, cospace)
inp = ift.Field.from_random(
domain=space, random_type='normal', std=1, mean=2, dtype=dtype)
inp = ift.Field.from_random(domain=space, random_type='normal', dtype=dtype, std=1, mean=2)
out = fft.times(inp)
fft2 = op(cospace, space)
out2 = fft2.inverse_times(inp)
......
......@@ -41,8 +41,7 @@ def test_dotsht(lm, tp):
a = ift.LMSpace(lmax=lm)
b = ift.GLSpace(nlat=lm + 1)
fft = ift.HarmonicTransformOperator(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=1, mean=0, dtype=tp)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=tp, std=1, mean=0)
out = fft.times(inp)
v1 = np.sqrt(out.s_vdot(out))
v2 = np.sqrt(inp.s_vdot(fft.adjoint_times(out)))
......@@ -54,8 +53,7 @@ def test_dotsht2(lm, tp):
a = ift.LMSpace(lmax=lm)
b = ift.HPSpace(nside=lm//2)
fft = ift.HarmonicTransformOperator(domain=a, target=b)
inp = ift.Field.from_random(
domain=a, random_type='normal', std=1, mean=0, dtype=tp)
inp = ift.Field.from_random(domain=a, random_type='normal', dtype=tp, std=1, mean=0)
out = fft.times(inp)
v1 = np.sqrt(out.s_vdot(out))
v2 = np.sqrt(inp.s_vdot(fft.adjoint_times(out)))
......@@ -67,8 +65,7 @@ def test_normalisation(space, tp):
tol = 10*_get_rtol(tp)
cospace = space.get_default_codomain()
fft = ift.HarmonicTransformOperator(space, cospace)
inp = ift.Field.from_random(
domain=space, random_type='normal', std=1, mean=2, dtype=tp)
inp = ift.Field.from_random(domain=space, random_type='normal', dtype=tp, std=1, mean=2)
out = fft.times(inp)
zero_idx = tuple([0]*len(space.shape))
assert_allclose(
......
......@@ -33,7 +33,7 @@ seed = list2fixture([4, 78, 23])
def testInterpolationAccuracy(space, seed):
pos = ift.from_random('normal', space)
pos = ift.from_random(space, 'normal')
alpha = 1.5
qs = [0.73, pos.ptw("exp").val]
for q in qs:
......
......@@ -39,7 +39,7 @@ ntries = 10
def testBasics(space, seed):
with ift.random.Context(seed):
s = ift.from_random('normal', space)
s = ift.from_random(space, 'normal')
var = ift.Linearization.make_var(s)
model = ift.ScalingOperator(var.target, 6.)
ift.extra.check_jacobian_consistency(model, var.val, ntries=ntries)
......@@ -55,42 +55,42 @@ def testBinary(type1, type2, space, seed):
select_s1 = ift.ducktape(None, dom1, "s1")
select_s2 = ift.ducktape(None, dom2, "s2")
model = select_s1*select_s2
pos = ift.from_random("normal", dom)
pos = ift.from_random(dom, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
model = select_s1 + select_s2
pos = ift.from_random("normal", dom)
pos = ift.from_random(dom, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
model = select_s1.scale(3.)
pos = ift.from_random("normal", dom1)
pos = ift.from_random(dom1, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
model = ift.Scaling