Commit de87751b authored by Philipp Arras's avatar Philipp Arras

Refactor

parent 19ab4fa3
Pipeline #72075 passed with stages
in 19 minutes and 54 seconds
......@@ -324,20 +324,20 @@ class MultiField(object):
val = tuple(f(v1, other) for v1 in self._val)
return MultiField(self._domain, val)
def _sinc_withjac(self):
return self._nontrivial_jac_helper('_sinc_withjac')
def _absolute_withjac(self):
return self._nontrivial_jac_helper('_absolute_withjac')
def _nontrivial_jac_helper(self, funcname):
val = self.to_dict()
jac = {}
for kk, vv in val.items():
val[kk], jac[kk] = getattr(vv, funcname)()
val = MultiField.from_dict(val, self._domain)
jac = MultiField.from_dict(jac, self._domain)
return val, jac
for op in ["sinc", "absolute"]:
ss = f'_{op}_withjac'
def func(ss):
def func2(self):
val = self.to_dict()
jac = {}
for kk, vv in val.items():
val[kk], jac[kk] = getattr(vv, ss)()
val = MultiField.from_dict(val, self._domain)
jac = MultiField.from_dict(jac, self._domain)
return val, jac
return func2
setattr(MultiField, ss, func(ss))
for op in ["__add__", "__radd__",
......
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