Skip to content

Commit

Permalink
remove Add._terms
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjanvanzwieten committed Apr 19, 2024
1 parent 182378a commit ab7183b
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions nutils/evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ab7183b

Please sign in to comment.