Commit ed8140ce authored by Philipp Arras's avatar Philipp Arras
Browse files

Add adjointness test

parent bfa349a5
......@@ -33,6 +33,8 @@ class RegriddingOperator(LinearOperator):
super(RegriddingOperator, self).__init__()
self._domain = DomainTuple.make(domain)
self._target = DomainTuple.make(target)
if any(np.array(self.domain.shape) < np.array(self.target.shape)):
print('Warning: The regridding operator is not intended to be used for upsampling.')
# domain: fine domain
# target: coarse domain
......@@ -69,6 +71,8 @@ class RegriddingOperator(LinearOperator):
# Throw away zero weights and flatten at the same time
mask = ws != 0
rs, cs, ws = rs[mask], cs[mask], ws[mask]
if np.sum(ws) != self.domain.size:
raise RuntimeError
smat = csr_matrix(
(ws, (rs, cs)), shape=(self.target.size, self.domain.size))
......
......@@ -248,3 +248,10 @@ class Consistency_Tests(unittest.TestCase):
tgt = ift.DomainTuple.make(args[0])
op = ift.QHTOperator(tgt, args[1])
ift.extra.consistency_check(op, dtype, dtype)
@expand([[ift.RGSpace(13, 52, 40), ift.RGSpace(4, 6, 25)],
[ift.RGSpace(128, 128), ift.RGSpace(45, 48)],
[ift.RGSpace(13), ift.RGSpace(7)]])
def testRegridding(self, domain, target):
op = ift.RegriddingOperator(domain, target)
ift.extra.consistency_check(op)
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