Skip to content

Commit

Permalink
api: avoid premature weight index substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Sep 24, 2024
1 parent d6d6759 commit 220280e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
11 changes: 0 additions & 11 deletions devito/finite_differences/differentiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ def coefficients(self):
key = lambda x: coeff_priority.get(x, -1)
return sorted(coefficients, key=key, reverse=True)[0]

@cached_property
def _coeff_symbol(self, *args, **kwargs):
if self._uses_symbolic_coefficients:
return W
else:
raise ValueError("Couldn't find any symbolic coefficients")

def _eval_at(self, func):
if not func.is_Staggered:
# Cartesian grid, do no waste time
Expand Down Expand Up @@ -435,10 +428,6 @@ def highest_priority(DiffOp):
return sorted(DiffOp._args_diff, key=prio, reverse=True)[0]


# Abstract symbol representing a symbolic coefficient
W = sympy.Function('W')


class DifferentiableOp(Differentiable):

__sympy_class__ = None
Expand Down
4 changes: 2 additions & 2 deletions devito/finite_differences/finite_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ def make_derivative(expr, dim, fd_order, deriv_order, side, matvec, x0, coeffici
# `coefficients` method (`taylor` or `symbolic`)
if weights is None:
weights = fd_weights_registry[coefficients](expr, deriv_order, indices, x0)
elif wdim is not None:
weights = [weights._subs(wdim, i) for i in range(len(indices))]

# Enforce fixed precision FD coefficients to avoid variations in results
weights = [sympify(w).evalf(_PRECISION) for w in weights]
Expand Down Expand Up @@ -193,6 +191,8 @@ def make_derivative(expr, dim, fd_order, deriv_order, side, matvec, x0, coeffici
deriv = DiffDerivative(expr*weights, {dim: indices.free_dim})
else:
terms = []
if wdim is not None:
weights = [weights._subs(wdim, i) for i in range(len(indices))]
for i, c in zip(indices, weights):
# The FD term
term = expr._subs(dim, i) * c
Expand Down

0 comments on commit 220280e

Please sign in to comment.