Commit 7c883532 authored by Martin Reinecke's avatar Martin Reinecke

demo implementation

parent 19a7c1ed
...@@ -74,11 +74,9 @@ class LogRGSpace(StructuredDomain): ...@@ -74,11 +74,9 @@ class LogRGSpace(StructuredDomain):
% (self.shape, self.harmonic)) % (self.shape, self.harmonic))
def get_default_codomain(self): def get_default_codomain(self):
if self._harmonic:
raise ValueError("only supported for nonharmonic space")
codomain_bindistances = 1. / (self.bindistances * self.shape) codomain_bindistances = 1. / (self.bindistances * self.shape)
return LogRGSpace(self.shape, codomain_bindistances, return LogRGSpace(self.shape, codomain_bindistances,
np.zeros(len(self.shape)), True) self._t_0, True)
def get_k_length_array(self): def get_k_length_array(self):
ib = dobj.ibegin_from_shape(self._shape) ib = dobj.ibegin_from_shape(self._shape)
......
...@@ -65,9 +65,9 @@ def make_amplitude_model(s_space, Npixdof, ceps_a, ceps_k, sm, sv, im, iv, ...@@ -65,9 +65,9 @@ def make_amplitude_model(s_space, Npixdof, ceps_a, ceps_k, sm, sv, im, iv,
p_space = PowerSpace(h_space) p_space = PowerSpace(h_space)
exp_transform = ExpTransform(p_space, Npixdof) exp_transform = ExpTransform(p_space, Npixdof)
logk_space = exp_transform.domain[0] logk_space = exp_transform.domain[0]
dof_space = logk_space.get_default_codomain() qht = QHTOperator(target=logk_space)
dof_space = qht.domain[0]
param_space = UnstructuredDomain(2) param_space = UnstructuredDomain(2)
qht = QHTOperator(dof_space, logk_space)
sym = SymmetrizingOperator(logk_space) sym = SymmetrizingOperator(logk_space)
phi_mean = np.array([sm, im]) phi_mean = np.array([sm, im])
......
...@@ -36,34 +36,28 @@ class QHTOperator(LinearOperator): ...@@ -36,34 +36,28 @@ class QHTOperator(LinearOperator):
Parameters Parameters
---------- ----------
domain : domain, tuple of domains or DomainTuple target : domain, tuple of domains or DomainTuple
The full input domain The full output domain
space : int space : int
The index of the domain on which the operator acts. The index of the domain on which the operator acts.
domain[space] must be a harmonic LogRGSpace. target[space] must be a nonharmonic LogRGSpace.
target : LogRGSpace
The target codomain of domain[space]
Must be a nonharmonic LogRGSpace.
""" """
def __init__(self, domain, target, space=0): def __init__(self, target, space=0):
self._domain = DomainTuple.make(domain) self._target = DomainTuple.make(target)
self._space = infer_space(self._domain, space) self._space = infer_space(self._target, space)
from ..domains.log_rg_space import LogRGSpace from ..domains.log_rg_space import LogRGSpace
if not isinstance(self._domain[self._space], LogRGSpace): if not isinstance(self._target[self._space], LogRGSpace):
raise ValueError("Domain[space] has to be a LogRGSpace!") raise ValueError("target[space] has to be a LogRGSpace!")
if not isinstance(target, LogRGSpace):
raise ValueError("Target has to be a LogRGSpace!")
if not self._domain[self._space].harmonic: if self._target[self._space].harmonic:
raise TypeError( raise TypeError(
"QHTOperator only works on a harmonic space") "target[space] must be a nonharmonic space")
if target.harmonic:
raise TypeError("Target is not a codomain of domain")
self._target = [dom for dom in self._domain] self._domain = [dom for dom in self._target]
self._target[self._space] = target self._domain[self._space] = \
self._target = DomainTuple.make(self._target) self._target[self._space].get_default_codomain()
self._domain = DomainTuple.make(self._domain)
@property @property
def domain(self): def domain(self):
......
...@@ -143,8 +143,6 @@ class Consistency_Tests(unittest.TestCase): ...@@ -143,8 +143,6 @@ class Consistency_Tests(unittest.TestCase):
ift.LogRGSpace(17, [3.], [.7])), 1)], ift.LogRGSpace(17, [3.], [.7])), 1)],
[np.float64])) [np.float64]))
def testQHTOperator(self, args, dtype): def testQHTOperator(self, args, dtype):
dom = ift.DomainTuple.make(args[0]) tgt = ift.DomainTuple.make(args[0])
tgt = list(dom) op = ift.QHTOperator(tgt, args[1])
tgt[args[1]] = tgt[args[1]].get_default_codomain()
op = ift.QHTOperator(tgt, dom[args[1]], args[1])
ift.extra.consistency_check(op, dtype, dtype) ift.extra.consistency_check(op, dtype, dtype)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment