From 8417b41657d69bd030cfcaacd61dac33a79f9fc4 Mon Sep 17 00:00:00 2001 From: ksagiyam Date: Sat, 16 Nov 2024 20:15:21 +0000 Subject: [PATCH] k --- firedrake/functionspaceimpl.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firedrake/functionspaceimpl.py b/firedrake/functionspaceimpl.py index 1d3bd2bf24..ac98149549 100644 --- a/firedrake/functionspaceimpl.py +++ b/firedrake/functionspaceimpl.py @@ -195,12 +195,15 @@ def _components(self): @PETSc.Log.EventDecorator() def sub(self, i): - #bound = len(self._components) - #if i < 0 or i >= bound: - # raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound)) if len(self) == 1: + bound = len(self._components) + if i < 0 or i >= bound: + raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound)) return self._components[i] else: + bound = len(self) + if i < 0 or i >= bound: + raise IndexError("Invalid index %d, not in [0, %d)" % (i, bound)) return self.subfunctions[i] @utils.cached_property