Commit e288f5be authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cosmetics

parent 9ebbecf5
...@@ -264,7 +264,7 @@ def empty_like(a, dtype=None): ...@@ -264,7 +264,7 @@ def empty_like(a, dtype=None):
def vdot(a, b): def vdot(a, b):
tmp = np.array(np.vdot(a._data, b._data)) tmp = np.array(np.vdot(a._data, b._data))
if a._distaxis==-1: if a._distaxis == -1:
return tmp[()] return tmp[()]
res = np.empty((), dtype=tmp.dtype) res = np.empty((), dtype=tmp.dtype)
_comm.Allreduce(tmp, res, MPI.SUM) _comm.Allreduce(tmp, res, MPI.SUM)
......
...@@ -621,6 +621,7 @@ class Field(object): ...@@ -621,6 +621,7 @@ class Field(object):
def positive_tanh(self): def positive_tanh(self):
return 0.5*(1.+self.tanh()) return 0.5*(1.+self.tanh())
for op in ["__add__", "__radd__", for op in ["__add__", "__radd__",
"__sub__", "__rsub__", "__sub__", "__rsub__",
"__mul__", "__rmul__", "__mul__", "__rmul__",
......
...@@ -119,9 +119,11 @@ class AmplitudeModel(Operator): ...@@ -119,9 +119,11 @@ class AmplitudeModel(Operator):
phi_sig = np.array([sv, iv]) phi_sig = np.array([sv, iv])
self._slope = SlopeOperator(param_space, logk_space, phi_sig) self._slope = SlopeOperator(param_space, logk_space, phi_sig)
self._norm_phi_mean = Field.from_global_data(param_space, phi_mean/phi_sig) self._norm_phi_mean = Field.from_global_data(param_space,
phi_mean/phi_sig)
self._domain = MultiDomain.make({keys[0]: dof_space, keys[1]: param_space}) self._domain = MultiDomain.make({keys[0]: dof_space,
keys[1]: param_space})
kern = lambda k: _ceps_kernel(dof_space, k, ceps_a, ceps_k) kern = lambda k: _ceps_kernel(dof_space, k, ceps_a, ceps_k)
cepstrum = create_cepstrum_amplitude_field(dof_space, kern) cepstrum = create_cepstrum_amplitude_field(dof_space, kern)
......
...@@ -47,7 +47,8 @@ class Linearization(object): ...@@ -47,7 +47,8 @@ class Linearization(object):
return Linearization(self._val[name], FieldAdapter(dom, name)) return Linearization(self._val[name], FieldAdapter(dom, name))
def __neg__(self): def __neg__(self):
return Linearization(-self._val, self._jac*(-1), return Linearization(
-self._val, self._jac*(-1),
None if self._metric is None else self._metric*(-1)) None if self._metric is None else self._metric*(-1))
def __add__(self, other): def __add__(self, other):
...@@ -77,7 +78,8 @@ class Linearization(object): ...@@ -77,7 +78,8 @@ class Linearization(object):
if isinstance(other, Linearization): if isinstance(other, Linearization):
d1 = makeOp(self._val) d1 = makeOp(self._val)
d2 = makeOp(other._val) d2 = makeOp(other._val)
return Linearization(self._val*other._val, return Linearization(
self._val*other._val,
RelaxedSumOperator((d2*self._jac, d1*other._jac))) RelaxedSumOperator((d2*self._jac, d1*other._jac)))
if isinstance(other, (int, float, complex)): if isinstance(other, (int, float, complex)):
# if other == 0: # if other == 0:
...@@ -100,8 +102,8 @@ class Linearization(object): ...@@ -100,8 +102,8 @@ class Linearization(object):
def sum(self): def sum(self):
from .sugar import full from .sugar import full
from .operators.vdot_operator import VdotOperator from .operators.vdot_operator import VdotOperator
return Linearization(full((),self._val.sum()), return Linearization(full((), self._val.sum()),
VdotOperator(full(self._jac.target,1))*self._jac) VdotOperator(full(self._jac.target, 1))*self._jac)
def exp(self): def exp(self):
tmp = self._val.exp() tmp = self._val.exp()
...@@ -132,4 +134,3 @@ class Linearization(object): ...@@ -132,4 +134,3 @@ class Linearization(object):
def make_const(field): def make_const(field):
from .operators.null_operator import NullOperator from .operators.null_operator import NullOperator
return Linearization(field, NullOperator({}, field.domain)) return Linearization(field, NullOperator({}, field.domain))
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