Commit 32119550 authored by Rouven Lemmerz's avatar Rouven Lemmerz
Browse files

change from_random argument order and default to 'normal'

parent 895884f3
......@@ -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.ScalingOperator(space, 2.456)(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 = (2.456*(select_s1*select_s2)).ptw("sigmoid")
pos = ift.from_random("normal", dom)
pos = ift.from_random(dom, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
pos = ift.from_random("normal", dom)
model = ift.OuterProduct(pos['s1'], ift.makeDomain(space))
pos = ift.from_random(dom, "normal")
model = ift.OuterProduct(ift.makeDomain(space), pos['s1'])
ift.extra.check_jacobian_consistency(model, pos['s2'], ntries=ntries)
model = select_s1**2
pos = ift.from_random("normal", dom1)
pos = ift.from_random(dom1, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
model = select_s1.clip(-1, 1)
pos = ift.from_random("normal", dom1)
pos = ift.from_random(dom1, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
f = ift.from_random("normal", space)
f = ift.from_random(space, "normal")
model = select_s1.clip(f-0.1, f+1.)
pos = ift.from_random("normal", dom1)
pos = ift.from_random(dom1, "normal")
ift.extra.check_jacobian_consistency(model, pos, ntries=ntries)
if isinstance(space, ift.RGSpace):
model = ift.FFTOperator(space)(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)
def testSpecialDistributionOps(space, seed):
with ift.random.Context(seed):
pos = ift.from_random('normal', space)
pos = ift.from_random(space, 'normal')
alpha = 1.5
q = 0.73
model = ift.InverseGammaOperator(space, alpha, q)
......@@ -102,8 +102,8 @@ def testSpecialDistributionOps(space, seed):
@pmp('neg', [True, False])
def testAdder(space, seed, neg):
with ift.random.Context(seed):
f = ift.from_random('normal', space)
f1 = ift.from_random('normal', space)
f = ift.from_random(space, 'normal')
f1 = ift.from_random(space, 'normal')
op = ift.Adder(f1, neg)
ift.extra.check_jacobian_consistency(op, f, ntries=ntries)
op = ift.Adder(f1.val.ravel()[0], neg=neg, domain=space)
......@@ -124,7 +124,7 @@ def testDynamicModel(target, causal, minimum_phase, seed):
'causal': causal,
'minimum_phase': minimum_phase}
model, _ = ift.dynamic_operator(**dct)
pos = ift.from_random('normal', model.domain)
pos = ift.from_random(model.domain, 'normal')
ift.extra.check_jacobian_consistency(model, pos, tol=1e-7, ntries=ntries)
if len(target.shape) > 1:
dct = {
......@@ -143,7 +143,7 @@ def testDynamicModel(target, causal, minimum_phase, seed):
dct['sigc'] = 1.
dct['quant'] = 5
model, _ = ift.dynamic_lightcone_operator(**dct)
pos = ift.from_random('normal', model.domain)
pos = ift.from_random(model.domain, 'normal')
ift.extra.check_jacobian_consistency(model, pos, tol=1e-7, ntries=ntries)
......@@ -159,5 +159,5 @@ def testNormalization(h_space, specialbinbounds, logarithmic, nbin):
binbounds = ift.PowerSpace.useful_binbounds(h_space, logarithmic, nbin)
dom = ift.PowerSpace(h_space, binbounds)
op = ift.library.correlated_fields._Normalization(dom)
pos = 0.1*ift.from_random('normal', op.domain)
pos = 0.1 * ift.from_random(op.domain, 'normal')
ift.extra.check_jacobian_consistency(op, pos, ntries=10)
......@@ -72,7 +72,7 @@ def test_cartesian():
GM = ift.GridderMaker(dom, uv=uv)
op = GM.getFull().adjoint
fld = ift.from_random('normal', dom)
fld = ift.from_random(dom, 'normal')
arr = fld.val
fld2 = ift.makeField(dom, np.roll(arr, (nx//2, ny//2), axis=(0, 1)))
......
......@@ -38,7 +38,7 @@ def test_part_mf_insert():
a = op1 + op2 + op3
b = op4 + op5
op = a.partial_insert(b)
fld = ift.from_random('normal', op.domain)
fld = ift.from_random(op.domain, 'normal')
ift.extra.check_jacobian_consistency(op, fld, ntries=ntries)
assert_(op.domain is ift.MultiDomain.union(
[op1.domain, op2.domain, op4.domain, op5.domain]))
......
......@@ -30,5 +30,5 @@ s = list2fixture([
def test_value(s):
Regrid = ift.RegriddingOperator(s, s.shape)
f = ift.from_random('normal', Regrid.domain)
f = ift.from_random(Regrid.domain, 'normal')
assert_allclose(f.val, Regrid(f).val)
......@@ -53,8 +53,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))
_check_repr(ift.SandwichOperator.make(a, b))
_check_repr(a(b))
_check_repr(a+b)
......@@ -73,7 +73,7 @@ def testLinearInterpolator():
@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))
_check_repr(op.adjoint)
_check_repr(op.inverse)
_check_repr(op.inverse.adjoint)
......@@ -137,7 +137,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