From 02bd9520259fcd56e717f6dd1dba0f5b9de9c983 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 27 Jul 2021 23:11:32 +0200 Subject: [PATCH] fix time stats nested loops 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. --- nutils/evaluable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nutils/evaluable.py b/nutils/evaluable.py index 81bd2c51b..0dc59bf54 100644 --- a/nutils/evaluable.py +++ b/nutils/evaluable.py @@ -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)] @@ -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)]