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
...@@ -71,6 +71,13 @@ the generation of reproducible random numbers in the presence of MPI parallelism ...@@ -71,6 +71,13 @@ the generation of reproducible random numbers in the presence of MPI parallelism
and leads to cleaner code overall. Please see the documentation of and leads to cleaner code overall. Please see the documentation of
`nifty6.random` for details. `nifty6.random` for details.
Interface Change for from_random and OuterProduct
=================================================
The sugar.from_random, Field.from_random, MultiField.from_random now take domain
as the first argument and default to 'normal' for the second argument.
Likewise OuterProduct takes domain as the first argument and a field as the second.
Interface Change for non-linear Operators Interface Change for non-linear Operators
========================================= =========================================
......
...@@ -43,7 +43,7 @@ if __name__ == '__main__': ...@@ -43,7 +43,7 @@ if __name__ == '__main__':
harmonic_space = position_space.get_default_codomain() harmonic_space = position_space.get_default_codomain()
HT = ift.HarmonicTransformOperator(harmonic_space, position_space) 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 # Define power spectrum and amplitudes
def sqrtpspec(k): def sqrtpspec(k):
...@@ -58,13 +58,13 @@ if __name__ == '__main__': ...@@ -58,13 +58,13 @@ if __name__ == '__main__':
# Generate mock data # Generate mock data
p = R(sky) 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) tmp = p(mock_position).val.astype(np.float64)
data = ift.random.current_rng().binomial(1, tmp) data = ift.random.current_rng().binomial(1, tmp)
data = ift.Field.from_raw(R.target, data) data = ift.Field.from_raw(R.target, data)
# Compute likelihood and Hamiltonian # Compute likelihood and Hamiltonian
position = ift.from_random('normal', harmonic_space) position = ift.from_random(harmonic_space, 'normal')
likelihood = ift.BernoulliEnergy(data) @ p likelihood = ift.BernoulliEnergy(data) @ p
ic_newton = ift.DeltaEnergyController( ic_newton = ift.DeltaEnergyController(
name='Newton', iteration_limit=100, tol_rel_deltaE=1e-8) name='Newton', iteration_limit=100, tol_rel_deltaE=1e-8)
......
...@@ -40,7 +40,7 @@ def make_checkerboard_mask(position_space): ...@@ -40,7 +40,7 @@ def make_checkerboard_mask(position_space):
def make_random_mask(): def make_random_mask():
# Random mask for spherical mode # Random mask for spherical mode
mask = ift.from_random('pm1', position_space) mask = ift.from_random(position_space, 'pm1')
mask = (mask + 1)/2 mask = (mask + 1)/2
return mask.val return mask.val
......
...@@ -90,7 +90,7 @@ if __name__ == '__main__': ...@@ -90,7 +90,7 @@ if __name__ == '__main__':
# Generate mock data and define likelihood operator # Generate mock data and define likelihood operator
d_space = R.target[0] d_space = R.target[0]
lamb = R(sky) lamb = R(sky)
mock_position = ift.from_random('normal', domain) mock_position = ift.from_random(domain, 'normal')
data = lamb(mock_position) data = lamb(mock_position)
data = ift.random.current_rng().poisson(data.val.astype(np.float64)) data = ift.random.current_rng().poisson(data.val.astype(np.float64))
data = ift.Field.from_raw(d_space, data) data = ift.Field.from_raw(d_space, data)
...@@ -103,7 +103,7 @@ if __name__ == '__main__': ...@@ -103,7 +103,7 @@ if __name__ == '__main__':
# Compute MAP solution by minimizing the information Hamiltonian # Compute MAP solution by minimizing the information Hamiltonian
H = ift.StandardHamiltonian(likelihood) 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 = ift.EnergyAdapter(initial_position, H, want_metric=True)
H, convergence = minimizer(H) H, convergence = minimizer(H)
......
...@@ -98,7 +98,7 @@ if __name__ == '__main__': ...@@ -98,7 +98,7 @@ if __name__ == '__main__':
N = ift.ScalingOperator(data_space, noise) N = ift.ScalingOperator(data_space, noise)
# Generate mock signal and data # 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) data = signal_response(mock_position) + N.draw_sample_with_dtype(dtype=np.float64)
# Minimization parameters # Minimization parameters
......
...@@ -97,7 +97,7 @@ if __name__ == '__main__': ...@@ -97,7 +97,7 @@ if __name__ == '__main__':
N = ift.ScalingOperator(data_space, noise) N = ift.ScalingOperator(data_space, noise)
# Generate mock signal and data # 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) data = signal_response(mock_position) + N.draw_sample_with_dtype(dtype=np.float64)
plot = ift.Plot() plot = ift.Plot()
......
...@@ -42,8 +42,8 @@ def _adjoint_implementation(op, domain_dtype, target_dtype, atol, rtol, ...@@ -42,8 +42,8 @@ def _adjoint_implementation(op, domain_dtype, target_dtype, atol, rtol,
needed_cap = op.TIMES | op.ADJOINT_TIMES needed_cap = op.TIMES | op.ADJOINT_TIMES
if (op.capability & needed_cap) != needed_cap: if (op.capability & needed_cap) != needed_cap:
return return
f1 = from_random("normal", op.domain, dtype=domain_dtype) f1 = from_random(op.domain, "normal", dtype=domain_dtype)
f2 = from_random("normal", op.target, dtype=target_dtype) f2 = from_random(op.target, "normal", dtype=target_dtype)
res1 = f1.s_vdot(op.adjoint_times(f2)) res1 = f1.s_vdot(op.adjoint_times(f2))
res2 = op.times(f1).s_vdot(f2) res2 = op.times(f1).s_vdot(f2)
if only_r_linear: if only_r_linear:
...@@ -55,11 +55,11 @@ def _inverse_implementation(op, domain_dtype, target_dtype, atol, rtol): ...@@ -55,11 +55,11 @@ def _inverse_implementation(op, domain_dtype, target_dtype, atol, rtol):
needed_cap = op.TIMES | op.INVERSE_TIMES needed_cap = op.TIMES | op.INVERSE_TIMES
if (op.capability & needed_cap) != needed_cap: if (op.capability & needed_cap) != needed_cap:
return 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)) res = op(op.inverse_times(foo))
assert_allclose(res, foo, atol=atol, rtol=rtol) 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)) res = op.inverse_times(op(foo))
assert_allclose(res, foo, atol=atol, rtol=rtol) assert_allclose(res, foo, atol=atol, rtol=rtol)
...@@ -75,8 +75,8 @@ def _check_linearity(op, domain_dtype, atol, rtol): ...@@ -75,8 +75,8 @@ def _check_linearity(op, domain_dtype, atol, rtol):
needed_cap = op.TIMES needed_cap = op.TIMES
if (op.capability & needed_cap) != needed_cap: if (op.capability & needed_cap) != needed_cap:
return return
fld1 = from_random("normal", op.domain, dtype=domain_dtype) fld1 = from_random(op.domain, "normal", dtype=domain_dtype)
fld2 = from_random("normal", op.domain, dtype=domain_dtype) fld2 = from_random(op.domain, "normal", dtype=domain_dtype)
alpha = np.random.random() # FIXME: this can break badly with MPI! alpha = np.random.random() # FIXME: this can break badly with MPI!
val1 = op(alpha*fld1+fld2) val1 = op(alpha*fld1+fld2)
val2 = alpha*op(fld1)+op(fld2) val2 = alpha*op(fld1)+op(fld2)
...@@ -88,7 +88,7 @@ def _actual_domain_check_linear(op, domain_dtype=None, inp=None): ...@@ -88,7 +88,7 @@ def _actual_domain_check_linear(op, domain_dtype=None, inp=None):
if (op.capability & needed_cap) != needed_cap: if (op.capability & needed_cap) != needed_cap:
return return
if domain_dtype is not None: 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: elif inp is None:
raise ValueError('Need to specify either dtype or inp') raise ValueError('Need to specify either dtype or inp')
assert_(inp.domain is op.domain) assert_(inp.domain is op.domain)
...@@ -219,7 +219,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64, ...@@ -219,7 +219,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
def _get_acceptable_location(op, loc, lin): def _get_acceptable_location(op, loc, lin):
if not np.isfinite(lin.val.s_sum()): if not np.isfinite(lin.val.s_sum()):
raise ValueError('Initial value must be finite') raise ValueError('Initial value must be finite')
dir = from_random("normal", loc.domain) dir = from_random(loc.domain, "normal")
dirder = lin.jac(dir) dirder = lin.jac(dir)
if dirder.norm() == 0: if dirder.norm() == 0:
dir = dir * (lin.val.norm()*1e-5) dir = dir * (lin.val.norm()*1e-5)
......
...@@ -124,7 +124,7 @@ class Field(Operator): ...@@ -124,7 +124,7 @@ class Field(Operator):
return Field(DomainTuple.make(new_domain), self._val) return Field(DomainTuple.make(new_domain), self._val)
@staticmethod @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. """Draws a random field with the given parameters.
Parameters Parameters
...@@ -283,7 +283,7 @@ class Field(Operator): ...@@ -283,7 +283,7 @@ class Field(Operator):
raise TypeError("The multiplier must be an instance of " + raise TypeError("The multiplier must be an instance of " +
"the Field class") "the Field class")
from .operators.outer_product_operator import OuterProduct from .operators.outer_product_operator import OuterProduct
return OuterProduct(self, x.domain)(x) return OuterProduct(x.domain, self)(x)
def vdot(self, x, spaces=None): def vdot(self, x, spaces=None):
"""Computes the dot product of 'self' with x. """Computes the dot product of 'self' with x.
......
...@@ -524,7 +524,7 @@ class CorrelatedFieldMaker: ...@@ -524,7 +524,7 @@ class CorrelatedFieldMaker:
for kk, op in lst: for kk, op in lst:
sc = StatCalculator() sc = StatCalculator()
for _ in range(prior_info): 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 mean = sc.mean.val
stddev = sc.var.ptw("sqrt").val stddev = sc.var.ptw("sqrt").val
for m, s in zip(mean.flatten(), stddev.flatten()): for m, s in zip(mean.flatten(), stddev.flatten()):
...@@ -539,7 +539,7 @@ class CorrelatedFieldMaker: ...@@ -539,7 +539,7 @@ class CorrelatedFieldMaker:
scm = 1. scm = 1.
for a in self._a: for a in self._a:
op = a.fluctuation_amplitude*self._azm.ptw("reciprocal") 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)]) for _ in range(nsamples)])
scm *= res**2 + 1. scm *= res**2 + 1.
return fluctuations_slice_mean/np.mean(np.sqrt(scm)) return fluctuations_slice_mean/np.mean(np.sqrt(scm))
......
...@@ -101,7 +101,7 @@ class MultiField(Operator): ...@@ -101,7 +101,7 @@ class MultiField(Operator):
return self._transform(lambda x: x.imag) return self._transform(lambda x: x.imag)
@staticmethod @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. """Draws a random multi-field with the given parameters.
Parameters Parameters
...@@ -131,7 +131,7 @@ class MultiField(Operator): ...@@ -131,7 +131,7 @@ class MultiField(Operator):
else: else:
dtype = np.dtype(dtype) dtype = np.dtype(dtype)
dtype = {kk: dtype for kk in domain.keys()} 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()} for kk in domain.keys()}
return MultiField.from_dict(dct) return MultiField.from_dict(dct)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
from ..multi_domain import MultiDomain from ..multi_domain import MultiDomain
from ..multi_field import MultiField from ..multi_field import MultiField
from .endomorphic_operator import EndomorphicOperator from .endomorphic_operator import EndomorphicOperator
from .linear_operator import LinearOperator
class BlockDiagonalOperator(EndomorphicOperator): class BlockDiagonalOperator(EndomorphicOperator):
""" """
...@@ -38,7 +38,13 @@ class BlockDiagonalOperator(EndomorphicOperator): ...@@ -38,7 +38,13 @@ class BlockDiagonalOperator(EndomorphicOperator):
self._capability = self._all_ops self._capability = self._all_ops
for op in self._ops: for op in self._ops:
if op is not None: if op is not None:
self._capability &= op.capability if isinstance(op, LinearOperator):
if op.target is not op.domain:
raise TypeError("domain and target mismatch")
self._capability &= op.capability
else:
raise TypeError("LinearOperator expected")
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
...@@ -55,7 +61,7 @@ class BlockDiagonalOperator(EndomorphicOperator): ...@@ -55,7 +61,7 @@ class BlockDiagonalOperator(EndomorphicOperator):
val = tuple( val = tuple(
op.draw_sample_with_dtype(dtype[key], from_inverse) op.draw_sample_with_dtype(dtype[key], from_inverse)
if op is not None 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())) for op, key in zip(self._ops, self._domain.keys()))
return MultiField(self._domain, val) return MultiField(self._domain, val)
......
...@@ -161,8 +161,7 @@ class DiagonalOperator(EndomorphicOperator): ...@@ -161,8 +161,7 @@ class DiagonalOperator(EndomorphicOperator):
return Field(self._domain, res) return Field(self._domain, res)
def draw_sample_with_dtype(self, dtype, from_inverse=False): def draw_sample_with_dtype(self, dtype, from_inverse=False):
res = Field.from_random(random_type="normal", domain=self._domain, res = Field.from_random(domain=self._domain, random_type="normal", dtype=dtype)
dtype=dtype)
return self.process_sample(res, from_inverse) return self.process_sample(res, from_inverse)
def __repr__(self): def __repr__(self):
......
...@@ -35,7 +35,7 @@ class DomainTupleFieldInserter(LinearOperator): ...@@ -35,7 +35,7 @@ class DomainTupleFieldInserter(LinearOperator):
Slice in new sub-domain in which the input field shall be written into. 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: if not space <= len(target) or space < 0:
raise ValueError raise ValueError
self._target = DomainTuple.make(target) self._target = DomainTuple.make(target)
...@@ -48,13 +48,13 @@ class DomainTupleFieldInserter(LinearOperator): ...@@ -48,13 +48,13 @@ class DomainTupleFieldInserter(LinearOperator):
nshp = new_space.shape nshp = new_space.shape
fst_dims = sum(len(dd.shape) for dd in self.target[:space]) 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") 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: if p < 0 or p >= s:
raise ValueError("bad position value") raise ValueError("bad position value")
self._slc = (slice(None),)*fst_dims + pos self._slc = (slice(None),)*fst_dims + index
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
......
...@@ -272,6 +272,7 @@ class HarmonicTransformOperator(LinearOperator): ...@@ -272,6 +272,7 @@ class HarmonicTransformOperator(LinearOperator):
- an LMSpace and a GLSpace - an LMSpace and a GLSpace
The supported operations are times() and adjoint_times(). The supported operations are times() and adjoint_times().
If inverse_times() on RGSpaces is needed the HartleyOperator should be used instead.
Parameters Parameters
---------- ----------
......
...@@ -27,12 +27,12 @@ class OuterProduct(LinearOperator): ...@@ -27,12 +27,12 @@ class OuterProduct(LinearOperator):
Parameters Parameters
--------- ---------
field: Field,
domain: DomainTuple, the domain of the input field domain: DomainTuple, the domain of the input field
field: Field
--------- ---------
""" """
def __init__(self, field, domain): def __init__(self, domain, field):
self._domain = domain self._domain = DomainTuple.make(domain)
self._field = field self._field = field
self._target = DomainTuple.make( self._target = DomainTuple.make(
tuple(sub_d for sub_d in field.domain._dom + domain._dom)) tuple(sub_d for sub_d in field.domain._dom + domain._dom))
......
...@@ -93,8 +93,7 @@ class ScalingOperator(EndomorphicOperator): ...@@ -93,8 +93,7 @@ class ScalingOperator(EndomorphicOperator):
def draw_sample_with_dtype(self, dtype, from_inverse=False): def draw_sample_with_dtype(self, dtype, from_inverse=False):
from ..sugar import from_random from ..sugar import from_random
return from_random(random_type="normal", domain=self._domain, return from_random(domain=self._domain, random_type="normal", dtype=dtype, std=self._get_fct(from_inverse))
std=self._get_fct(from_inverse), dtype=dtype)
def __call__(self, other): def __call__(self, other):
res = EndomorphicOperator.__call__(self, other) res = EndomorphicOperator.__call__(self, other)
......
...@@ -36,7 +36,7 @@ class SliceOperator(LinearOperator): ...@@ -36,7 +36,7 @@ class SliceOperator(LinearOperator):
---------- ----------
domain : Domain, DomainTuple or tuple of Domain domain : Domain, DomainTuple or tuple of Domain
The operator's input domain. The operator's input domain.
tgt_shape : tuple of integers or None new_shape : tuple of integers or None
The shape of the target domain with None indicating to copy the shape The shape of the target domain with None indicating to copy the shape
of the original domain for this axis. of the original domain for this axis.
center : bool, optional center : bool, optional
...@@ -44,11 +44,11 @@ class SliceOperator(LinearOperator): ...@@ -44,11 +44,11 @@ class SliceOperator(LinearOperator):
preserve_dist: bool, optional preserve_dist: bool, optional
Whether to preserve the distance of the input field. Whether to preserve the distance of the input field.
""" """
def __init__(self, domain, tgt_shape, center=False, preserve_dist=True): def __init__(self, domain, new_shape, center=False, preserve_dist=True):
self._domain = DomainTuple.make(domain) self._domain = DomainTuple.make(domain)
if len(tgt_shape) != len(self._domain.shape): if len(new_shape) != len(self._domain.shape):
ve = ( ve = (
f"shape ({tgt_shape}) is incompatible with the shape of the" f"shape ({new_shape}) is incompatible with the shape of the"
f" domain ({self._domain.shape})" f" domain ({self._domain.shape})"
) )
raise ValueError(ve) raise ValueError(ve)
...@@ -56,9 +56,9 @@ class SliceOperator(LinearOperator): ...@@ -56,9 +56,9 @@ class SliceOperator(LinearOperator):
tgt = [] tgt = []
slc_by_ax = [] slc_by_ax = []
for i, d in enumerate(self._domain): for i, d in enumerate(self._domain):
if tgt_shape[i] is None or self._domain.shape[i] == tgt_shape[i]: if new_shape[i] is None or self._domain.shape[i] == new_shape[i]:
tgt += [d] tgt += [d]
elif tgt_shape[i] < self._domain.shape[i]: elif new_shape[i] < self._domain.shape[i]:
dom_kw = dict() dom_kw = dict()
if isinstance(d, RGSpace): if isinstance(d, RGSpace):
if preserve_dist: if preserve_dist:
...@@ -68,22 +68,22 @@ class SliceOperator(LinearOperator): ...@@ -68,22 +68,22 @@ class SliceOperator(LinearOperator):
# Some domains like HPSpace or LMSPace can not be sliced # Some domains like HPSpace or LMSPace can not be sliced
ve = f"{d.__class__.__name__} can not be sliced" ve = f"{d.__class__.__name__} can not be sliced"
raise ValueError(ve) raise ValueError(ve)
tgt += [d.__class__(tgt_shape[i], **dom_kw)] tgt += [d.__class__(new_shape[i], **dom_kw)]
else: else:
ve = ( ve = (
f"domain axes ({d}) is smaller than the target shape" f"domain axes ({d}) is smaller than the target shape"
f"{tgt_shape[i]}" f"{new_shape[i]}"
) )
raise ValueError(ve) raise ValueError(ve)
if center: if center:
slc_start = np.floor( slc_start = np.floor(
(self._domain.shape[i] - tgt_shape[i]) / 2. (self._domain.shape[i] - new_shape[i]) / 2.
).astype(int) ).astype(int)
slc_end = slc_start + tgt_shape[i] slc_end = slc_start + new_shape[i]
else: else:
slc_start = 0 slc_start = 0
slc_end = tgt_shape[i] slc_end = new_shape[i]
slc_by_ax += [slice(slc_start, slc_end)] slc_by_ax += [slice(slc_start, slc_end)]
self._slc_by_ax = tuple(slc_by_ax) self._slc_by_ax = tuple(slc_by_ax)
......
...@@ -130,9 +130,9 @@ class FieldAdapter(LinearOperator): ...@@ -130,9 +130,9 @@ class FieldAdapter(LinearOperator):
The relevant key of the MultiDomain. The relevant key of the MultiDomain.
""" """
def __init__(self, tgt, name): def __init__(self, target, name):
from ..sugar import makeDomain from ..sugar import makeDomain
tmp = makeDomain(tgt) tmp = makeDomain(target)
if isinstance(tmp, DomainTuple): if isinstance(tmp, DomainTuple):
self._target = tmp self._target = tmp
self._domain = MultiDomain.make({name: tmp}) self._domain = MultiDomain.make({name: tmp})
...@@ -175,9 +175,9 @@ class _SlowFieldAdapter(LinearOperator): ...@@ -175,9 +175,9 @@ class _SlowFieldAdapter(LinearOperator):
The relevant key of the MultiDomain. The relevant key of the MultiDomain.
""" """
def __init__(self, dom, name): def __init__(self, domain, name):
from ..sugar import makeDomain from ..sugar import makeDomain
tmp = makeDomain(dom) tmp = makeDomain(domain)
if not isinstance(tmp, MultiDomain): if not isinstance(tmp, MultiDomain):
raise TypeError("MultiDomain expected") raise TypeError("MultiDomain expected")
self._name = str(name) self._name = str(name)
......
...@@ -134,7 +134,7 @@ def probe_diagonal(op, nprobes, random_type="pm1"): ...@@ -134,7 +134,7 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
''' '''
sc = StatCalculator() sc = StatCalculator()
for i in range(nprobes): for i in range(nprobes):
x = from_random(random_type,