Commit aba85fd
committed
Pin UWexpression _op_priority back to sympy default (avoid Matrix/UWexpression regression)
The previous commit set MathematicalMixin._op_priority = 11.5 to win
sympy dispatch over Matrix (10.01) for the bare-variable composition
case. UWexpression inherits from MathematicalMixin (first in MRO), so
that change inadvertently bumped UWexpression's priority too — and
UWexpression has its OWN __rtruediv__ (and __rmul__, etc.) for sympy
interop. Its __rmul__ explicitly handles MutableDenseMatrix; its
__rtruediv__ does not, falling through to Symbol.__rtruediv__ which
fails on MatrixBase.
Result: solvers that compute Matrix / UWexpression (e.g. SNES_Diffusion's
F0 expression `self.DuDt.bdf(0) / self.delta_t` at solvers.py:2499)
broke with TypeError on every transient/Darcy/AdvDiff path. CI surfaced
this on test_1005, test_1006, test_1100, test_1110.
Fix: explicitly set UWexpression._op_priority = 10.0 to opt out of the
mixin's bump. UWexpression already handles Matrix dispatch correctly
through its own dunders (and via sympy's standard machinery for
fall-through cases); it doesn't need the priority bump that pure
MathematicalMixin classes (EnhancedMeshVariable, SwarmVariable) need.
Verified:
- #137 4-case reproducer still passes (the original fix is intact).
- Previously-failing tests all pass: test_1005_TransientDarcyCartesian,
test_1006_RichardsCartesian, test_1100_AdvDiffCartesian,
test_1110_advDiffAnnulus — 8/8 pass.
- pytest -m "level_1 and tier_a" on amr-dev: 56 passed, 3 skipped,
0 failed.
Underworld development team with AI support from Claude Code1 parent 57d156c commit aba85fd
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
632 | 644 | | |
633 | 645 | | |
634 | 646 | | |
| |||
0 commit comments