Commit 3541b181 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'metric_and_jacobian_fixups' into 'NIFTy_6'

Metric and jacobian fixups

See merge request !423
parents e7da3d40 06e7f0a9
Pipeline #70800 passed with stages
in 59 minutes and 41 seconds
......@@ -15,6 +15,8 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..field import Field
from ..multi_field import MultiField
from .operator import Operator
......@@ -168,11 +170,9 @@ class LinearOperator(Operator):
def __call__(self, x):
"""Same as :meth:`times`"""
from ..field import Field
from ..multi_field import MultiField
from ..linearization import Linearization
if isinstance(x, (Field, MultiField)):
return self.apply(x, self.TIMES)
from ..linearization import Linearization
if isinstance(x, Linearization):
return x.new(self(x._val), self).prepend_jac(x.jac)
return self@x
......
......@@ -52,6 +52,10 @@ class SandwichOperator(EndomorphicOperator):
cheese: EndomorphicOperator
the cheese part
"""
if isinstance(cheese, SandwichOperator):
old_cheese = cheese
cheese = old_cheese._cheese
bun = old_cheese._bun @ bun
if not isinstance(bun, LinearOperator):
raise TypeError("bun must be a linear operator")
if cheese is not None and not isinstance(cheese, LinearOperator):
......@@ -62,7 +66,7 @@ class SandwichOperator(EndomorphicOperator):
else:
op = bun.adjoint(cheese(bun))
# if our sandwich is diagonal, we can return immediately
# If our sandwich is diagonal, we can return immediately
if isinstance(op, (ScalingOperator, DiagonalOperator)):
return op
return SandwichOperator(bun, cheese, op, _callingfrommake=True)
......
......@@ -91,9 +91,6 @@ class ScalingOperator(EndomorphicOperator):
raise ValueError("operator not positive definite")
return 1./np.sqrt(fct) if from_inverse else np.sqrt(fct)
# def process_sample(self, samp, from_inverse):
# return samp*self._get_fct(from_inverse)
def draw_sample(self, from_inverse=False, dtype=np.float64):
from ..sugar import from_random
return from_random(random_type="normal", domain=self._domain,
......
Supports Markdown
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