Commit 1d9d8541 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

more renamings

parent 97974970
Pipeline #72567 failed with stages
in 19 minutes and 58 seconds
......@@ -19,7 +19,7 @@ for ii in range(10, 26):
uvspace = ift.RGSpace((nu, nv))
visspace = ift.UnstructuredDomain(N)
visspace = ift.UnstructuredSpace(N)
img = rng.standard_normal((nu, nv))
img = ift.makeField(uvspace, img)
......
......@@ -68,7 +68,7 @@ if __name__ == '__main__':
HT = ift.HarmonicTransformOperator(harmonic_space, position_space)
# Domain on which the field's degrees of freedom are defined
domain = ift.DomainTuple.make(harmonic_space)
domain = ift.SpaceTuple.make(harmonic_space)
# Define amplitude (square root of power spectrum)
def sqrtpspec(k):
......
......@@ -48,19 +48,19 @@ class PolynomialResponse(ift.LinearOperator):
Parameters
----------
domain: UnstructuredDomain
domain: UnstructuredSpace
The domain on which the coefficients of the polynomial are defined.
sampling_points: Numpy array
x-values of the sampling points.
"""
def __init__(self, domain, sampling_points):
if not (isinstance(domain, ift.UnstructuredDomain)
if not (isinstance(domain, ift.UnstructuredSpace)
and isinstance(x, np.ndarray)):
raise TypeError
self._domain = ift.DomainTuple.make(domain)
tgt = ift.UnstructuredDomain(sampling_points.shape)
self._target = ift.DomainTuple.make(tgt)
self._domain = ift.SpaceTuple.make(domain)
tgt = ift.UnstructuredSpace(sampling_points.shape)
self._target = ift.SpaceTuple.make(tgt)
self._capability = self.TIMES | self.ADJOINT_TIMES
sh = (self.target.size, domain.size)
......@@ -93,7 +93,7 @@ if __name__ == '__main__':
y[5] -= 0
# Set up minimization problem
p_space = ift.UnstructuredDomain(N_params)
p_space = ift.UnstructuredSpace(N_params)
params = ift.full(p_space, 0.)
R = PolynomialResponse(p_space, x)
ift.extra.consistency_check(R)
......
......@@ -3,8 +3,8 @@ from .version import __version__
from . import random
from .domains.domain import Domain
from .domains.structured_domain import StructuredDomain
from .domains.unstructured_domain import UnstructuredDomain
from .domains.structured_domain import StructuredSpace
from .domains.unstructured_domain import UnstructuredSpace
from .domains.rg_space import RGSpace
from .domains.lm_space import LMSpace
from .domains.gl_space import GLSpace
......@@ -12,8 +12,8 @@ from .domains.hp_space import HPSpace
from .domains.power_space import PowerSpace
from .domains.dof_space import DOFSpace
from .domain_tuple import DomainTuple
from .multi_domain import MultiDomain
from .domain_tuple import SpaceTuple
from .multi_domain import SpaceTupleDict
from .field import Field
from .multi_field import MultiField
......@@ -24,7 +24,7 @@ from .operators.linear_operator import LinearOperator
from .operators.adder import Adder
from .operators.diagonal_operator import DiagonalOperator
from .operators.distributors import DOFDistributor, PowerDistributor
from .operators.domain_tuple_field_inserter import DomainTupleFieldInserter
from .operators.domain_tuple_field_inserter import SpaceTupleFieldInserter
from .operators.contraction_operator import ContractionOperator
from .operators.linear_interpolation import LinearInterpolator
from .operators.endomorphic_operator import EndomorphicOperator
......
......@@ -22,7 +22,7 @@ from .domains.domain import Domain
import numpy as np
class DomainTuple(object):
class SpaceTuple(object):
"""Ordered sequence of Domain objects.
This class holds a tuple of :class:`Domain` objects, which together form
......@@ -33,7 +33,7 @@ class DomainTuple(object):
Notes
-----
DomainTuples should never be created using the constructor, but rather
SpaceTuples should never be created using the constructor, but rather
via the factory function :attr:`make`!
"""
_tupleCache = {}
......@@ -59,26 +59,26 @@ class DomainTuple(object):
@staticmethod
def make(domain):
"""Returns a DomainTuple matching `domain`.
"""Returns a SpaceTuple matching `domain`.
This function checks whether a matching DomainTuple already exists.
If yes, this object is returned, otherwise a new DomainTuple object
This function checks whether a matching SpaceTuple already exists.
If yes, this object is returned, otherwise a new SpaceTuple object
is created and returned.
Parameters
----------
domain : Domain or tuple of Domain or DomainTuple
The geometrical structure for which the DomainTuple shall be
domain : Domain or tuple of Domain or SpaceTuple
The geometrical structure for which the SpaceTuple shall be
obtained.
"""
if isinstance(domain, DomainTuple):
if isinstance(domain, SpaceTuple):
return domain
domain = DomainTuple._parse_domain(domain)
obj = DomainTuple._tupleCache.get(domain)
domain = SpaceTuple._parse_domain(domain)
obj = SpaceTuple._tupleCache.get(domain)
if obj is not None:
return obj
obj = DomainTuple(domain, _callingfrommake=True)
DomainTuple._tupleCache[domain] = obj
obj = SpaceTuple(domain, _callingfrommake=True)
SpaceTuple._tupleCache[domain] = obj
return obj
@staticmethod
......@@ -105,7 +105,7 @@ class DomainTuple(object):
"""tuple of int: number of pixels along each axis
The shape of the array-like object required to store information
defined on the DomainTuple.
defined on the SpaceTuple.
"""
return self._shape
......@@ -187,22 +187,22 @@ class DomainTuple(object):
return not self.__eq__(x)
def __str__(self):
return ("DomainTuple, len: {}\n".format(len(self)) +
return ("SpaceTuple, len: {}\n".format(len(self)) +
"\n".join(str(i) for i in self))
def __reduce__(self):
return (_unpickleDomainTuple, (self._dom,))
return (_unpickleSpaceTuple, (self._dom,))
@staticmethod
def scalar_domain():
if DomainTuple._scalarDomain is None:
DomainTuple._scalarDomain = DomainTuple.make(())
return DomainTuple._scalarDomain
if SpaceTuple._scalarDomain is None:
SpaceTuple._scalarDomain = SpaceTuple.make(())
return SpaceTuple._scalarDomain
def __repr__(self):
subs = "\n".join(sub.__repr__() for sub in self._dom)
return "DomainTuple:\n"+utilities.indent(subs)
return "SpaceTuple:\n"+utilities.indent(subs)
def _unpickleDomainTuple(*args):
return DomainTuple.make(*args)
def _unpickleSpaceTuple(*args):
return SpaceTuple.make(*args)
......@@ -17,10 +17,10 @@
import numpy as np
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class DOFSpace(StructuredDomain):
class DOFSpace(StructuredSpace):
"""Generic degree-of-freedom space. It is defined as the domain of some
DOFDistributor.
Its entries represent the underlying degrees of freedom of some other
......
......@@ -17,10 +17,10 @@
import numpy as np
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class GLSpace(StructuredDomain):
class GLSpace(StructuredSpace):
"""Represents a 2-sphere with Gauss-Legendre pixelization.
Its harmonic partner domain is the
......
......@@ -17,10 +17,10 @@
import numpy as np
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class HPSpace(StructuredDomain):
class HPSpace(StructuredSpace):
"""Represents 2-sphere with HEALPix discretization.
Its harmonic partner domain is the
......
......@@ -18,10 +18,10 @@
import numpy as np
from ..field import Field
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class LMSpace(StructuredDomain):
class LMSpace(StructuredSpace):
"""Represents a set of spherical harmonic coefficients.
Its harmonic partner spaces are :class:`~nifty6.domains.hp_space.HPSpace`
......
......@@ -17,10 +17,10 @@
import numpy as np
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class PowerSpace(StructuredDomain):
class PowerSpace(StructuredSpace):
"""Represents non-equidistantly binned spaces for power spectra.
A power space is the result of a projection of a harmonic domain where
......@@ -28,7 +28,7 @@ class PowerSpace(StructuredDomain):
Parameters
----------
harmonic_partner : StructuredDomain
harmonic_partner : StructuredSpace
The harmonic domain of which this is the power space.
binbounds : None, or tuple of float
By default (binbounds=None):
......@@ -107,7 +107,7 @@ class PowerSpace(StructuredDomain):
Parameters
----------
space : StructuredDomain
space : StructuredSpace
the domain for which the binbounds will be computed.
logarithmic : bool
If True bins will have equal size in linear space; otherwise they
......@@ -124,7 +124,7 @@ class PowerSpace(StructuredDomain):
empty bins, if `nbin` is not supplied.
The first and last bin boundary are inferred from `space`.
"""
if not (isinstance(space, StructuredDomain) and space.harmonic):
if not (isinstance(space, StructuredSpace) and space.harmonic):
raise ValueError("first argument must be a harmonic space.")
if logarithmic is None and nbin is None:
return None
......@@ -153,7 +153,7 @@ class PowerSpace(StructuredDomain):
return PowerSpace.linear_binbounds(nbin, lbound, rbound)
def __init__(self, harmonic_partner, binbounds=None):
if not (isinstance(harmonic_partner, StructuredDomain) and
if not (isinstance(harmonic_partner, StructuredSpace) and
harmonic_partner.harmonic):
raise ValueError("harmonic_partner must be a harmonic space.")
if harmonic_partner.scalar_dvol is None:
......@@ -224,7 +224,7 @@ class PowerSpace(StructuredDomain):
@property
def harmonic_partner(self):
"""StructuredDomain : the harmonic domain associated with `self`."""
"""StructuredSpace : the harmonic domain associated with `self`."""
return self._harmonic_partner
@property
......
......@@ -19,10 +19,10 @@ from functools import reduce
import numpy as np
from ..field import Field
from .structured_domain import StructuredDomain
from .structured_domain import StructuredSpace
class RGSpace(StructuredDomain):
class RGSpace(StructuredSpace):
"""Represents a regular Cartesian grid.
Parameters
......
......@@ -20,7 +20,7 @@ import numpy as np
from .domain import Domain
class StructuredDomain(Domain):
class StructuredSpace(Domain):
"""The abstract base class for all structured domains.
An instance of a space contains information about the manifold's
......
......@@ -19,7 +19,7 @@ from functools import reduce
from .domain import Domain
class UnstructuredDomain(Domain):
class UnstructuredSpace(Domain):
"""A :class:`~nifty6.domains.domain.Domain` subclass for spaces with no
associated geometry.
......@@ -41,7 +41,7 @@ class UnstructuredDomain(Domain):
self._shape = (int(shape), )
def __repr__(self):
return "UnstructuredDomain(shape={})".format(self.shape)
return "UnstructuredSpace(shape={})".format(self.shape)
@property
def shape(self):
......
......@@ -18,10 +18,10 @@
import numpy as np
from numpy.testing import assert_
from .domain_tuple import DomainTuple
from .domain_tuple import SpaceTuple
from .field import Field
from .linearization import Linearization
from .multi_domain import MultiDomain
from .multi_domain import SpaceTupleDict
from .multi_field import MultiField
from .operators.linear_operator import LinearOperator
from .sugar import from_random
......@@ -121,10 +121,10 @@ def _actual_domain_check_nonlinear(op, loc):
def _domain_check(op):
for dd in [op.domain, op.target]:
if not isinstance(dd, (DomainTuple, MultiDomain)):
if not isinstance(dd, (SpaceTuple, SpaceTupleDict)):
raise TypeError(
'The domain and the target of an operator need to '
'be instances of either DomainTuple or MultiDomain.')
'be instances of either SpaceTuple or SpaceTupleDict.')
def _performance_check(op, pos, raise_on_fail):
......
......@@ -19,7 +19,7 @@ from functools import reduce
import numpy as np
from . import utilities
from .domain_tuple import DomainTuple
from .domain_tuple import SpaceTuple
from .operand import Operand
......@@ -31,7 +31,7 @@ class Field(Operand):
Parameters
----------
target : DomainTuple
target : SpaceTuple
The target of the new Field.
val : numpy.ndarray
This object's shape must match the target shape
......@@ -43,11 +43,11 @@ class Field(Operand):
many convenience functions for instantiation!
"""
_scalar_dom = DomainTuple.scalar_domain()
_scalar_dom = SpaceTuple.scalar_domain()
def __init__(self, target, val):
if not isinstance(target, DomainTuple):
raise TypeError("target must be of type DomainTuple")
if not isinstance(target, SpaceTuple):
raise TypeError("target must be of type SpaceTuple")
if not isinstance(val, np.ndarray):
if np.isscalar(val):
val = np.full(target.shape, val)
......@@ -76,7 +76,7 @@ class Field(Operand):
Parameters
----------
target : Domain, tuple of Domain, or DomainTuple
target : Domain, tuple of Domain, or SpaceTuple
Domain of the new Field.
val : float/complex/int scalar
Fill value. Data type of the field is inferred from val.
......@@ -90,7 +90,7 @@ class Field(Operand):
raise TypeError("val must be a scalar")
if not (np.isreal(val) or np.iscomplex(val)):
raise TypeError("need arithmetic scalar")
target = DomainTuple.make(target)
target = SpaceTuple.make(target)
return Field(target, val)
@staticmethod
......@@ -99,20 +99,20 @@ class Field(Operand):
Parameters
----------
target : DomainTuple, tuple of Domain, or Domain
target : SpaceTuple, tuple of Domain, or Domain
The target of the new Field.
arr : numpy.ndarray
The data content to be used for the new Field.
Its shape must match the shape of `target`.
"""
return Field(DomainTuple.make(target), arr)
return Field(SpaceTuple.make(target), arr)
def cast_target(self, new_target):
"""Returns a field with the same data, but a different target
Parameters
----------
new_target : Domain, tuple of Domain, or DomainTuple
new_target : Domain, tuple of Domain, or SpaceTuple
The target for the returned field. Must be shape-compatible to
`self`.
......@@ -121,7 +121,7 @@ class Field(Operand):
Field
Field defined on `new_target`, but with the same data as `self`.
"""
return Field(DomainTuple.make(new_target), self._val)
return Field(SpaceTuple.make(new_target), self._val)
@staticmethod
def from_random(random_type, target, dtype=np.float64, **kwargs):
......@@ -131,7 +131,7 @@ class Field(Operand):
----------
random_type : 'pm1', 'normal', or 'uniform'
The random distribution to use.
target : DomainTuple
target : SpaceTuple
The target of the output random Field.
dtype : type
The datatype of the output random Field.
......@@ -142,7 +142,7 @@ class Field(Operand):
The newly created Field.
"""
from .random import Random
target = DomainTuple.make(target)
target = SpaceTuple.make(target)
generator_function = getattr(Random, random_type)
arr = generator_function(dtype=dtype, shape=target.shape, **kwargs)
return Field(target, arr)
......@@ -173,7 +173,7 @@ class Field(Operand):
@property
def target(self):
"""DomainTuple : the field's target"""
"""SpaceTuple : the field's target"""
return self._target
@property
......@@ -404,7 +404,7 @@ class Field(Operand):
for i, dom in enumerate(self._target)
if i not in spaces)
return Field(DomainTuple.make(return_target), data)
return Field(SpaceTuple.make(return_target), data)
def sum(self, spaces=None):
"""Sums up over the sub-domains given by `spaces`.
......
......@@ -21,9 +21,9 @@ from operator import mul
import numpy as np
from ..domain_tuple import DomainTuple
from ..domain_tuple import SpaceTuple
from ..domains.power_space import PowerSpace
from ..domains.unstructured_domain import UnstructuredDomain
from ..domains.unstructured_domain import UnstructuredSpace
from ..field import Field
from ..linearization import Linearization
from ..logger import logger
......@@ -68,12 +68,12 @@ def _lognormal_moments(mean, sig, N=0):
def _normal(mean, sig, key, N=0):
if N == 0:
domain = DomainTuple.scalar_domain()
domain = SpaceTuple.scalar_domain()
mean, sig = np.asfarray(mean), np.asfarray(sig)
return Adder(makeField(domain, mean)) @ (
sig * ducktape(domain, None, key))
domain = UnstructuredDomain(N)
domain = UnstructuredSpace(N)
mean, sig = (_reshaper(param, N) for param in (mean, sig))
return Adder(makeField(domain, mean)) @ (DiagonalOperator(
makeField(domain, sig)) @ ducktape(domain, None, key))
......@@ -87,7 +87,7 @@ def _log_k_lengths(pspace):
def _relative_log_k_lengths(power_space):
"""Log-distance to first bin
logkl.shape==power_space.shape, logkl[0]=logkl[1]=0"""
power_space = DomainTuple.make(power_space)
power_space = SpaceTuple.make(power_space)
assert isinstance(power_space[0], PowerSpace)
assert len(power_space) == 1
logkl = _log_k_lengths(power_space[0])
......@@ -104,7 +104,7 @@ def _log_vol(power_space):
def _structured_spaces(domain):
if isinstance(domain[0], UnstructuredDomain):
if isinstance(domain[0], UnstructuredSpace):
return np.arange(1, len(domain))
return np.arange(len(domain))
......@@ -169,7 +169,7 @@ class _TwoLogIntegrations(LinearOperator):
self._target = makeDomain(target)
assert isinstance(self.target[space], PowerSpace)
dom = list(self._target)
dom[space] = UnstructuredDomain((2, self.target[space].shape[0]-2))
dom[space] = UnstructuredSpace((2, self.target[space].shape[0]-2))
self._domain = makeDomain(dom)
self._space = space
self._log_vol = _log_vol(self._target[space])
......@@ -208,7 +208,7 @@ class _TwoLogIntegrations(LinearOperator):
class _Normalization(Operator):
def __init__(self, domain, space=0):
self._domain = self._target = DomainTuple.make(domain)
self._domain = self._target = SpaceTuple.make(domain)
assert isinstance(self._domain[space], PowerSpace)
hspace = list(self._domain)
hspace[space] = hspace[space].harmonic_partner
......@@ -279,9 +279,9 @@ class _Amplitude(Operator):
if len(dofdex) > 0:
N_copies = max(dofdex) + 1
space = 1
distributed_tgt = makeDomain((UnstructuredDomain(len(dofdex)),
distributed_tgt = makeDomain((UnstructuredSpace(len(dofdex)),
target))
target = makeDomain((UnstructuredDomain(N_copies), target))
target = makeDomain((UnstructuredSpace(N_copies), target))
Distributor = _Distributor(dofdex, target, distributed_tgt, 0)
else:
N_copies = 0
......@@ -397,7 +397,7 @@ class CorrelatedFieldMaker:
prefix + 'zeromode',
N)
if total_N > 0:
zm = _Distributor(dofdex, zm.target, UnstructuredDomain(total_N)) @ zm
zm = _Distributor(dofdex, zm.target, UnstructuredSpace(total_N)) @ zm
return CorrelatedFieldMaker(offset_mean, zm, prefix, total_N)
def add_fluctuations(self,
......@@ -427,7 +427,7 @@ class CorrelatedFieldMaker:
if self._total_N > 0:
N = max(dofdex) + 1
position_space = makeDomain((UnstructuredDomain(N), position_space))
position_space = makeDomain((UnstructuredSpace(N), position_space))
else:
N = 0
position_space = makeDomain(position_space)
......@@ -460,7 +460,7 @@ class CorrelatedFieldMaker:
n_amplitudes = len(self._a)
if self._total_N > 0:
hspace = makeDomain(
[UnstructuredDomain(self._total_N)] +
[UnstructuredSpace(self._total_N)] +
[dd.target[-1].harmonic_partner for dd in self._a])
spaces = tuple(range(1, n_amplitudes + 1))
amp_space = 1
......
......@@ -17,9 +17,9 @@
import numpy as np
from ..domain_tuple import DomainTuple
from ..domain_tuple import SpaceTuple
from ..domains.rg_space import RGSpace
from ..domains.unstructured_domain import UnstructuredDomain
from ..domains.unstructured_domain import UnstructuredSpace
from ..field import Field
from ..operators.diagonal_operator import DiagonalOperator
from ..operators.field_zero_padder import FieldZeroPadder
......@@ -58,7 +58,7 @@ def _make_dynamic_operator(target, harmonic_padding, sm_s0, sm_x0, cone, keys, c
if codomain is None:
codomain = target.get_default_codomain()
dom = DomainTuple.make(codomain)
dom = SpaceTuple.make(codomain)
ops = {}
FFT = FFTOperator(dom)
Real = Realizer(dom)
......@@ -111,7 +111,7 @@ def _make_dynamic_operator(target, harmonic_padding, sm_s0, sm_x0, cone, keys, c
sigc = list((sigc,)*(len(m.target.shape) - 1))
elif len(sigc) != len(m.target.shape) - 1:
raise (ValueError, "Shape mismatch!")
c = FieldAdapter(UnstructuredDomain(len(sigc)), keys[1])
c = FieldAdapter(UnstructuredSpace(len(sigc)), keys[1])
c = makeOp(Field(c.target, np.array(sigc)))(c)
lightspeed = ScalingOperator(c.target, -0.5)(c).ptw("exp")
......
......@@ -17,9 +17,9 @@
import numpy as np
from ..domain_tuple import DomainTuple
from ..domain_tuple import SpaceTuple
from ..domains.rg_space import RGSpace
from ..domains.unstructured_domain import UnstructuredDomain
from ..domains.unstructured_domain import UnstructuredSpace
from ..operators.linear_operator import LinearOperator
from ..sugar import makeField, makeDomain
......@@ -90,9 +90,9 @@ class _RestOperator(LinearOperator):
class RadioGridder(LinearOperator):
def __init__(self, grid_domain, bl, gconf, idx):
self._domain = DomainTuple.make(
UnstructuredDomain((bl.Nrows())))
self._target = DomainTuple.make(grid_domain)
self._domain = SpaceTuple.make(