From 53ef54150f921012fe0a2cecca1bddecc6d50973 Mon Sep 17 00:00:00 2001 From: David Ham Date: Mon, 12 Jan 2026 11:12:29 +0000 Subject: [PATCH] Fall back gracefully when sum factorisation fails. The sum factorisation implementation only works with up to 6 indices in a contraction. There are circumstances in which an interpolation kernel can exceed this. Rather than failing in this case, we should not sum factorise. --- finat/finiteelementbase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/finat/finiteelementbase.py b/finat/finiteelementbase.py index dd497a463..72fc83c64 100644 --- a/finat/finiteelementbase.py +++ b/finat/finiteelementbase.py @@ -277,7 +277,11 @@ def dual_evaluation(self, fn): # ignoring any shape indices to avoid hitting the sum- # factorisation index limit (this is a bit of a hack). # Really need to do a more targeted job here. - evaluation = gem.optimise.contraction(evaluation, shape_indices) + try: + evaluation = gem.optimise.contraction(evaluation, shape_indices) + except NotImplementedError as e: + if str(e) != "Too many indices for sum factorisation!": + raise return evaluation, basis_indices @abstractproperty