|
19 | 19 | from devito.tools import (as_tuple, filter_ordered, flatten, frozendict, |
20 | 20 | infer_dtype, extract_dtype, is_integer, split, is_number) |
21 | 21 | from devito.types import Array, DimensionTuple, Evaluable, StencilDimension |
22 | | -from devito.types.basic import AbstractFunction |
| 22 | +from devito.types.basic import AbstractFunction, Indexed |
23 | 23 |
|
24 | 24 | __all__ = ['Differentiable', 'DiffDerivative', 'IndexDerivative', 'EvalDerivative', |
25 | 25 | 'Weights', 'Real', 'Imag', 'Conj'] |
@@ -769,12 +769,22 @@ def free_symbols(self): |
769 | 769 | func = DifferentiableOp._rebuild |
770 | 770 |
|
771 | 771 |
|
| 772 | +class WeightsIndexed(Indexed): |
| 773 | + pass |
| 774 | + |
| 775 | + |
772 | 776 | class Weights(Array): |
773 | 777 |
|
774 | 778 | """ |
775 | 779 | The weights (or coefficients) of a finite-difference expansion. |
776 | 780 | """ |
777 | 781 |
|
| 782 | + # Use IndexedWeights for the underlying Indexed objects because they |
| 783 | + # are guaranteed to appear at the end on an expression's .args. |
| 784 | + # This makes it dramatically easier to implement substutions. It also makes |
| 785 | + # it easier to visually parse IndexDerivatives when looking at them |
| 786 | + _indexed_cls = WeightsIndexed |
| 787 | + |
778 | 788 | def __init_finalize__(self, *args, **kwargs): |
779 | 789 | dimensions = as_tuple(kwargs.get('dimensions')) |
780 | 790 | weights = kwargs.get('initvalue') |
|
0 commit comments