From bc057cde9a98aee84fa7ae92a4c60e47e39afbeb Mon Sep 17 00:00:00 2001 From: mloubout Date: Wed, 31 Jul 2024 11:13:47 -0400 Subject: [PATCH] builtins: fix gaussian kernel for non-square --- devito/builtins/initializers.py | 4 ++-- devito/finite_differences/tools.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devito/builtins/initializers.py b/devito/builtins/initializers.py index f2425173fc..5efa3dd610 100644 --- a/devito/builtins/initializers.py +++ b/devito/builtins/initializers.py @@ -145,9 +145,9 @@ def create_gaussian_weights(sigma, lw): weights = [w/w.sum() for w in (np.exp(-0.5/s**2*(np.linspace(-l, l, 2*l+1))**2) for s, l in zip(sigma, lw))] processed = [] - for w in weights: + for (w, l) in zip(weights, lw): temp = list(w) - while len(temp) < 2*max(lw)+1: + while len(temp) < 2*l+1: temp.insert(0, 0) temp.append(0) processed.append(np.array(temp)) diff --git a/devito/finite_differences/tools.py b/devito/finite_differences/tools.py index a387c4d18d..87cdd61481 100644 --- a/devito/finite_differences/tools.py +++ b/devito/finite_differences/tools.py @@ -229,7 +229,7 @@ def numeric_weights(function, deriv_order, indices, x0): coeff_priority = {'taylor': 1, 'standard': 1} -def generate_indices(expr, dim, order, side=None, matvec=None, x0=None, nweights=None): +def generate_indices(expr, dim, order, side=None, matvec=None, x0=None, nweights=0): """ Indices for the finite-difference scheme.