From 0b03c3db45a7b1d8261ee16fe57a5431a06c046c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Tue, 25 Nov 2008 23:30:05 -0500 Subject: [PATCH] Avoid side effects in evaluation for numpy arrays by not using in-place ops. --- src/mapper/evaluator.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mapper/evaluator.py b/src/mapper/evaluator.py index 48cb683..d5b3597 100644 --- a/src/mapper/evaluator.py +++ b/src/mapper/evaluator.py @@ -36,12 +36,8 @@ class EvaluationMapper(RecursiveMapper): return sum(self.rec(child) for child in expr.children) def map_product(self, expr): - if len(expr.children) == 0: - return 1 # FIXME? - result = self.rec(expr.children[0]) - for child in expr.children[1:]: - result *= self.rec(child) - return result + from pytools import product + return product(self.rec(child) for child in expr.children) def map_quotient(self, expr): return self.rec(expr.numerator) / self.rec(expr.denominator) -- GitLab