From 7fee99519a0f8594e04090fcb57c310e6d7a08b1 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Thu, 26 Oct 2023 08:49:46 +0000 Subject: [PATCH] compiler: Ensure Weights values are of type sympy --- devito/finite_differences/differentiable.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devito/finite_differences/differentiable.py b/devito/finite_differences/differentiable.py index cfaf732701..a20902a39a 100644 --- a/devito/finite_differences/differentiable.py +++ b/devito/finite_differences/differentiable.py @@ -617,12 +617,13 @@ def __init_finalize__(self, *args, **kwargs): assert isinstance(d, StencilDimension) and d.symbolic_size == len(weights) assert isinstance(weights, (list, tuple, np.ndarray)) - try: - self._spacings = set().union(*[i.find(Spacing) for i in weights]) - except AttributeError: - self._spacing = set() + # Normalize `weights` + weights = tuple(sympy.sympify(i) for i in weights) + + self._spacings = set().union(*[i.find(Spacing) for i in weights]) kwargs['scope'] = 'constant' + kwargs['initvalue'] = weights super().__init_finalize__(*args, **kwargs)