Commit 32119550 authored by Rouven Lemmerz's avatar Rouven Lemmerz

change from_random argument order and default to 'normal'

parent 895884f3
Pipeline #75211 passed with stages
in 8 minutes and 22 seconds
......@@ -43,7 +43,7 @@ if __name__ == '__main__':
harmonic_space = position_space.get_default_codomain()
HT = ift.HarmonicTransformOperator(harmonic_space, position_space)
position = ift.from_random('normal', harmonic_space)
position = ift.from_random(harmonic_space, 'normal')
# Define power spectrum and amplitudes
def sqrtpspec(k):
......@@ -58,13 +58,13 @@ if __name__ == '__main__':
# Generate mock data
p = R(sky)
mock_position = ift.from_random('normal', harmonic_space)
mock_position = ift.from_random(harmonic_space, 'normal')
tmp = p(mock_position).val.astype(np.float64)
data = ift.random.current_rng().binomial(1, tmp)
data = ift.Field.from_raw(R.target, data)
# Compute likelihood and Hamiltonian
position = ift.from_random('normal', harmonic_space)
position = ift.from_random(harmonic_space, 'normal')
likelihood = ift.BernoulliEnergy(data) @ p
ic_newton = ift.DeltaEnergyController(
name='Newton', iteration_limit=100, tol_rel_deltaE=1e-8)
......
......@@ -40,7 +40,7 @@ def make_checkerboard_mask(position_space):
def make_random_mask():
# Random mask for spherical mode
mask = ift.from_random('pm1', position_space)
mask = ift.from_random(position_space, 'pm1')
mask = (mask + 1)/2
return mask.val
......
......@@ -90,7 +90,7 @@ if __name__ == '__main__':
# Generate mock data and define likelihood operator
d_space = R.target[0]
lamb = R(sky)
mock_position = ift.from_random('normal', domain)
mock_position = ift.from_random(domain, 'normal')
data = lamb(mock_position)
data = ift.random.current_rng().poisson(data.val.astype(np.float64))
data = ift.Field.from_raw(d_space, data)
......@@ -103,7 +103,7 @@ if __name__ == '__main__':
# Compute MAP solution by minimizing the information Hamiltonian
H = ift.StandardHamiltonian(likelihood)
initial_position = ift.from_random('normal', domain)
initial_position = ift.from_random(domain, 'normal')
H = ift.EnergyAdapter(initial_position, H, want_metric=True)
H, convergence = minimizer(H)
......
......@@ -98,7 +98,7 @@ if __name__ == '__main__':
N = ift.ScalingOperator(data_space, noise)
# Generate mock signal and data
mock_position = ift.from_random('normal', signal_response.domain)
mock_position = ift.from_random(signal_response.domain, 'normal')
data = signal_response(mock_position) + N.draw_sample_with_dtype(dtype=np.float64)
# Minimization parameters
......
......@@ -97,7 +97,7 @@ if __name__ == '__main__':
N = ift.ScalingOperator(data_space, noise)
# Generate mock signal and data
mock_position = ift.from_random('normal', signal_response.domain)
mock_position = ift.from_random(signal_response.domain, 'normal')
data = signal_response(mock_position) + N.draw_sample_with_dtype(dtype=np.float64)
plot = ift.Plot()
......
......@@ -42,8 +42,8 @@ def _adjoint_implementation(op, domain_dtype, target_dtype, atol, rtol,
needed_cap = op.TIMES | op.ADJOINT_TIMES
if (op.capability & needed_cap) != needed_cap:
return
f1 = from_random("normal", op.domain, dtype=domain_dtype)
f2 = from_random("normal", op.target, dtype=target_dtype)
f1 = from_random(op.domain, "normal", dtype=domain_dtype)
f2 = from_random(op.target, "normal", dtype=target_dtype)
res1 = f1.s_vdot(op.adjoint_times(f2))
res2 = op.times(f1).s_vdot(f2)
if only_r_linear:
......@@ -55,11 +55,11 @@ def _inverse_implementation(op, domain_dtype, target_dtype, atol, rtol):
needed_cap = op.TIMES | op.INVERSE_TIMES
if (op.capability & needed_cap) != needed_cap:
return
foo = from_random("normal", op.target, dtype=target_dtype)
foo = from_random(op.target, "normal", dtype=target_dtype)
res = op(op.inverse_times(foo))
assert_allclose(res, foo, atol=atol, rtol=rtol)
foo = from_random("normal", op.domain, dtype=domain_dtype)
foo = from_random(op.domain, "normal", dtype=domain_dtype)
res = op.inverse_times(op(foo))
assert_allclose(res, foo, atol=atol, rtol=rtol)
......@@ -75,8 +75,8 @@ def _check_linearity(op, domain_dtype, atol, rtol):
needed_cap = op.TIMES
if (op.capability & needed_cap) != needed_cap:
return
fld1 = from_random("normal", op.domain, dtype=domain_dtype)
fld2 = from_random("normal", op.domain, dtype=domain_dtype)
fld1 = from_random(op.domain, "normal", dtype=domain_dtype)
fld2 = from_random(op.domain, "normal", dtype=domain_dtype)
alpha = np.random.random() # FIXME: this can break badly with MPI!
val1 = op(alpha*fld1+fld2)
val2 = alpha*op(fld1)+op(fld2)
......@@ -88,7 +88,7 @@ def _actual_domain_check_linear(op, domain_dtype=None, inp=None):
if (op.capability & needed_cap) != needed_cap:
return
if domain_dtype is not None:
inp = from_random("normal", op.domain, dtype=domain_dtype)
inp = from_random(op.domain, "normal", dtype=domain_dtype)
elif inp is None:
raise ValueError('Need to specify either dtype or inp')
assert_(inp.domain is op.domain)
......@@ -219,7 +219,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
def _get_acceptable_location(op, loc, lin):
if not np.isfinite(lin.val.s_sum()):
raise ValueError('Initial value must be finite')
dir = from_random("normal", loc.domain)
dir = from_random(loc.domain, "normal")
dirder = lin.jac(dir)
if dirder.norm() == 0:
dir = dir * (lin.val.norm()*1e-5)
......
......@@ -124,7 +124,7 @@ class Field(Operator):
return Field(DomainTuple.make(new_domain), self._val)
@staticmethod
def from_random(random_type, domain, dtype=np.float64, **kwargs):
def from_random(domain, random_type='normal', dtype=np.float64, **kwargs):
"""Draws a random field with the given parameters.
Parameters
......
......@@ -524,7 +524,7 @@ class CorrelatedFieldMaker:
for kk, op in lst:
sc = StatCalculator()
for _ in range(prior_info):
sc.add(op(from_random('normal', op.domain)))
sc.add(op(from_random(op.domain, 'normal')))
mean = sc.mean.val
stddev = sc.var.ptw("sqrt").val
for m, s in zip(mean.flatten(), stddev.flatten()):
......@@ -539,7 +539,7 @@ class CorrelatedFieldMaker:
scm = 1.
for a in self._a:
op = a.fluctuation_amplitude*self._azm.ptw("reciprocal")
res = np.array([op(from_random('normal', op.domain)).val
res = np.array([op(from_random(op.domain, 'normal')).val
for _ in range(nsamples)])
scm *= res**2 + 1.
return fluctuations_slice_mean/np.mean(np.sqrt(scm))
......
......@@ -101,7 +101,7 @@ class MultiField(Operator):
return self._transform(lambda x: x.imag)
@staticmethod
def from_random(random_type, domain, dtype=np.float64, **kwargs):
def from_random(domain, random_type='normal', dtype=np.float64, **kwargs):
"""Draws a random multi-field with the given parameters.
Parameters
......@@ -131,7 +131,7 @@ class MultiField(Operator):
else:
dtype = np.dtype(dtype)
dtype = {kk: dtype for kk in domain.keys()}
dct = {kk: Field.from_random(random_type, domain[kk], dtype[kk], **kwargs)
dct = {kk: Field.from_random(domain[kk], random_type, dtype[kk], **kwargs)
for kk in domain.keys()}
return MultiField.from_dict(dct)
......
......@@ -61,7 +61,7 @@ class BlockDiagonalOperator(EndomorphicOperator):
val = tuple(
op.draw_sample_with_dtype(dtype[key], from_inverse)
if op is not None
else from_random('normal', self._domain[key], dtype=dtype)
else from_random(self._domain[key], 'normal', dtype=dtype)
for op, key in zip(self._ops, self._domain.keys()))
return MultiField(self._domain, val)
......
......@@ -161,8 +161,7 @@ class DiagonalOperator(EndomorphicOperator):
return Field(self._domain, res)
def draw_sample_with_dtype(self, dtype, from_inverse=False):
res = Field.from_random(random_type="normal", domain=self._domain,
dtype=dtype)
res = Field.from_random(domain=self._domain, random_type="normal", dtype=dtype)
return self.process_sample(res, from_inverse)
def __repr__(self):
......
......@@ -35,7 +35,7 @@ class DomainTupleFieldInserter(LinearOperator):
Slice in new sub-domain in which the input field shall be written into.
"""
def __init__(self, target, space, pos):
def __init__(self, target, space, index):
if not space <= len(target) or space < 0:
raise ValueError
self._target = DomainTuple.make(target)
......@@ -48,13 +48,13 @@ class DomainTupleFieldInserter(LinearOperator):
nshp = new_space.shape
fst_dims = sum(len(dd.shape) for dd in self.target[:space])
if len(pos) != len(nshp):
if len(index) != len(nshp):
raise ValueError("shape mismatch between new_space and position")
for s, p in zip(nshp, pos):
for s, p in zip(nshp, index):
if p < 0 or p >= s:
raise ValueError("bad position value")
self._slc = (slice(None),)*fst_dims + pos
self._slc = (slice(None),)*fst_dims + index
def apply(self, x, mode):
self._check_input(x, mode)
......
......@@ -93,8 +93,7 @@ class ScalingOperator(EndomorphicOperator):
def draw_sample_with_dtype(self, dtype, from_inverse=False):
from ..sugar import from_random
return from_random(random_type="normal", domain=self._domain,
std=self._get_fct(from_inverse), dtype=dtype)
return from_random(domain=self._domain, random_type="normal", dtype=dtype, std=self._get_fct(from_inverse))
def __call__(self, other):
res = EndomorphicOperator.__call__(self, other)
......
......@@ -134,7 +134,7 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
'''
sc = StatCalculator()
for i in range(nprobes):
x = from_random(random_type, op.domain)
x = from_random(op.domain, random_type)
sc.add(op(x).conjugate()*x)
return sc.mean
......
......@@ -256,7 +256,7 @@ def full(domain, val):
return Field.full(domain, val)
def from_random(random_type, domain, dtype=np.float64, **kwargs):
def from_random(domain, random_type='normal', dtype=np.float64, **kwargs):
"""Convenience function creating Fields/MultiFields with random values.
Parameters
......@@ -283,8 +283,8 @@ def from_random(random_type, domain, dtype=np.float64, **kwargs):
random numbers, even for the same initial RNG state.
"""
if isinstance(domain, (dict, MultiDomain)):
return MultiField.from_random(random_type, domain, dtype, **kwargs)
return Field.from_random(random_type, domain, dtype, **kwargs)
return MultiField.from_random(domain, random_type, dtype, **kwargs)
return Field.from_random(domain, random_type, dtype, **kwargs)
def makeField(domain, arr):
......@@ -466,7 +466,7 @@ def exec_time(obj, want_metric=True):
logger.info('Energy.metric(position): {}'.format(time() - t0))
elif isinstance(obj, Operator):
want_metric = bool(want_metric)
pos = from_random('normal', obj.domain)
pos = from_random(obj.domain, 'normal')
t0 = time()
obj(pos)
logger.info('Operator call with field: {}'.format(time() - t0))
......@@ -509,7 +509,7 @@ def calculate_position(operator, output):
lh = GaussianEnergy(d, invcov) @ operator
H = StandardHamiltonian(
lh, ic_samp=GradientNormController(iteration_limit=200))
pos = 0.1*from_random('normal', operator.domain)
pos = 0.1 * from_random(operator.domain, 'normal')
minimizer = NewtonCG(GradientNormController(iteration_limit=10))
for ii in range(3):
kl = MetricGaussianKL(pos, H, 3, mirror_samples=True)
......
......@@ -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)))
......@@ -297,8 +297,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)
......@@ -341,7 +341,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():
......
......@@ -38,7 +38,7 @@ def test_kl(constants, point_estimates, mirror_samples, 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
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)