Commit 3de57d9c authored by Philipp Arras's avatar Philipp Arras
Browse files

KLMetric -> SelfAdjointOperatorWrapper

parent a2ccbfa2
...@@ -97,15 +97,16 @@ def _reduce_by_keys(field, operator, keys): ...@@ -97,15 +97,16 @@ def _reduce_by_keys(field, operator, keys):
return field, operator return field, operator
class _KLMetric(EndomorphicOperator): class _SelfAdjointOperatorWrapper(EndomorphicOperator):
def __init__(self, KL): def __init__(self, domain, func):
self._KL = KL from ..sugar import makeDomain
self._func = func
self._capability = self.TIMES | self.ADJOINT_TIMES self._capability = self.TIMES | self.ADJOINT_TIMES
self._domain = KL.position.domain self._domain = makeDomain(domain)
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
return self._KL.apply_metric(x) return self._func(x)
class _SampledKLEnergy(Energy): class _SampledKLEnergy(Energy):
...@@ -175,7 +176,8 @@ class _SampledKLEnergy(Energy): ...@@ -175,7 +176,8 @@ class _SampledKLEnergy(Energy):
@property @property
def metric(self): def metric(self):
return _KLMetric(self) return _SelfAdjointOperatorWrapper(self.position.domain,
self.apply_metric)
@property @property
def samples(self): def samples(self):
......
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