Skip to content

Commit

Permalink
fix time stats nested loops
Browse files Browse the repository at this point in the history
With nested loops, the inner `LoopSum` or `LoopConcatenateCombined` incorrectly
created a new dictionary for inner time stats for every outer iteration. This
patch fixes this problem by creating a new dictionary only if there was none.
  • Loading branch information
joostvanzwieten committed Aug 27, 2021
1 parent 6066e87 commit 02bd952
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nutils/evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3483,7 +3483,7 @@ def evalf(self, shape, length, *args):

def evalf_withtimes(self, times, shape, length, *args):
serialized = self._serialized
times[self] = subtimes = collections.defaultdict(_Stats)
subtimes = times.setdefault(self, collections.defaultdict(_Stats))
result = numpy.zeros(shape, self.dtype)
for index in range(length):
values = [numpy.array(index)]
Expand Down Expand Up @@ -3686,7 +3686,7 @@ def evalf(self, shapes, length, *args):

def evalf_withtimes(self, times, shapes, length, *args):
serialized = self._serialized
times[self] = subtimes = collections.defaultdict(_Stats)
subtimes = times.setdefault(self, collections.defaultdict(_Stats))
results = [parallel.shempty(tuple(map(int, shape)), dtype=func.dtype) for func, shape in zip(self._funcs, shapes)]
for index in range(length):
values = [numpy.array(index)]
Expand Down

0 comments on commit 02bd952

Please sign in to comment.