From f8fa8417d9fb71fe47e50035003e8f042510547e Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Mon, 2 Aug 2021 23:15:30 +0200 Subject: [PATCH] fix LoopSum.asarray assertion In `LoopSum.asarray` the axes that are invariant to the loop index are shuffled to the start to minimize the number of ravels. After the shuffle and ravels all but the last axes are asserted to be invariant to the loop index. The check, however, incorrectly checks for constness, which is more strict than being invariant to the loop index. This patch fixes the assertion and removes an `int` check, which is always false since the shapes are always of type `evaluable.Array`. --- nutils/evaluable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nutils/evaluable.py b/nutils/evaluable.py index 0dc59bf54..d334b8e05 100644 --- a/nutils/evaluable.py +++ b/nutils/evaluable.py @@ -3545,11 +3545,11 @@ def _assparse(self): *elem_indices, elem_values = (InsertAxis(arr, 1) for arr in (*elem_indices, elem_values)) else: # minimize ravels by transposing all variable length axes to the end - variable = tuple(i for i, n in enumerate(elem_values.shape) if not numeric.isint(n) and self.index in n.arguments) + variable = tuple(i for i, n in enumerate(elem_values.shape) if self.index in n.arguments) *elem_indices, elem_values = (Transpose.to_end(arr, *variable) for arr in (*elem_indices, elem_values)) for i in variable[:-1]: *elem_indices, elem_values = map(Ravel, (*elem_indices, elem_values)) - assert all(n.isconstant for n in elem_values.shape[:-1]) + assert all(self.index not in n.arguments for n in elem_values.shape[:-1]) chunks.append(tuple(loop_concatenate(arr, self.index) for arr in (*elem_indices, elem_values))) return tuple(chunks)