Commit 66cf9aa5 authored by Martin Reinecke's avatar Martin Reinecke

anticipate a few nice changes from symbolicDifferentiation

parent 8657bf15
Pipeline #30032 passed with stages
in 9 minutes and 34 seconds
......@@ -10,8 +10,8 @@ if __name__ == "__main__":
p_spec = lambda k: (1. / (k*correlation_length + 1) ** 4)
nonlinearity = Tanh()
#nonlinearity = Linear()
#nonlinearity = Exponential()
# nonlinearity = Linear()
# nonlinearity = Exponential()
# Set up position space
s_space = ift.RGSpace(1024)
......
......@@ -28,5 +28,5 @@ from .multi import *
__all__ = ["__version__", "dobj", "DomainTuple"] + \
domains.__all__ + operators.__all__ + minimization.__all__ + \
["DomainTuple", "Field", "sqrt", "exp", "log"] + \
["DomainTuple", "Field", "sqrt", "exp", "log", "tanh"] + \
multi.__all__
......@@ -97,5 +97,5 @@ class LineEnergy(object):
if abs(res.imag) / max(abs(res.real), 1.) > 1e-12:
from ..logger import logger
logger.warning("directional derivative has non-negligible "
"imaginary part:", res)
"imaginary part: {}".format(res))
return res.real
......@@ -98,7 +98,7 @@ class ScipyMinimizer(Minimizer):
r = opt.minimize(hlp.fun, x, method=self._method, jac=hlp.jac,
hessp=hessp, options=self._options, bounds=bounds)
if not r.success:
logger.error("Problem in Scipy minimization:", r.message)
logger.error("Problem in Scipy minimization: {}".format(r.message))
return hlp._energy, IterationController.ERROR
return hlp._energy, IterationController.CONVERGED
......
......@@ -130,16 +130,22 @@ class LinearOperator(NiftyMetaBase()):
def __mul__(self, other):
from .chain_operator import ChainOperator
if np.isscalar(other) and other == 1.:
return self
other = self._toOperator(other, self.domain)
return ChainOperator.make([self, other])
def __rmul__(self, other):
from .chain_operator import ChainOperator
if np.isscalar(other) and other == 1.:
return self
other = self._toOperator(other, self.target)
return ChainOperator.make([other, self])
def __add__(self, other):
from .sum_operator import SumOperator
if np.isscalar(other) and other == 0.:
return self
other = self._toOperator(other, self.domain)
return SumOperator.make([self, other], [False, False])
......@@ -148,6 +154,8 @@ class LinearOperator(NiftyMetaBase()):
def __sub__(self, other):
from .sum_operator import SumOperator
if np.isscalar(other) and other == 0.:
return self
other = self._toOperator(other, self.domain)
return SumOperator.make([self, other], [False, True])
......
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