From ab7183b99fe2472ae261903909d7e853dc81d423 Mon Sep 17 00:00:00 2001 From: Gertjan van Zwieten Date: Thu, 18 Apr 2024 16:41:34 +0200 Subject: [PATCH] remove Add._terms --- nutils/evaluable.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/nutils/evaluable.py b/nutils/evaluable.py index 741ceead2..d26be324d 100644 --- a/nutils/evaluable.py +++ b/nutils/evaluable.py @@ -1630,14 +1630,6 @@ def _inflations(self): inflations.append((axis, types.frozendict((dofmap, util.sum(parts[dofmap] for parts in (parts1, parts2) if dofmap in parts)) for dofmap in dofmaps))) return tuple(inflations) - @property - def _terms(self): - for func in self.funcs: - if isinstance(func, Add): - yield from func._terms - else: - yield func - @util.reentrant_iter.property def representations(self): yield add, tuple(self.funcs) @@ -1672,18 +1664,19 @@ def _simplified(self): evalf = staticmethod(numpy.add) def _derivative(self, var, seen): - return add(*[derivative(f, var, seen) for f in self._terms]) + func1, func2 = self.funcs + return derivative(func1, var, seen) + derivative(func2, var, seen) @cached_property def _assparse(self): if self.dtype == bool: return super()._assparse - else: - return _gathersparsechunks(itertools.chain(*[f._assparse for f in self._terms])) + func1, func2 = self.funcs + return _gathersparsechunks(func1._assparse + func2._assparse) def _intbounds_impl(self): - lowers, uppers = zip(*[f._intbounds for f in self._terms]) - return builtins.sum(lowers), builtins.sum(uppers) + (lower1, upper1), (lower2, upper2) = [f._intbounds for f in self.funcs] + return lower1 + lower2, upper1 + upper2 class Einsum(Array):