Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3059 +/- ##
==========================================
- Coverage 84.26% 84.25% -0.01%
==========================================
Files 258 258
Lines 56982 57189 +207
Branches 4854 4893 +39
==========================================
+ Hits 48016 48187 +171
- Misses 8139 8171 +32
- Partials 827 831 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mloubout
left a comment
There was a problem hiding this comment.
Not quite like that much complexity added to filter one type of expression
| return reuse_if_untouched(expr, [subs_if_composite(e, subs) for e in expr]) | ||
| elif all(isinstance(i, (Indexed, IndexDerivative)) for i in subs): | ||
| return uxreplace(expr, subs) | ||
| if all(isinstance(i, (Indexed, IndexDerivative)) for i in subs): |
There was a problem hiding this comment.
why not just a single dispatch instead of carrying that func around
|
|
||
|
|
||
| def _subs_if_composite(expr, func): | ||
| if type(expr) in (tuple, list): |
There was a problem hiding this comment.
same, suingle dispatch would be cleaner
| pass | ||
|
|
||
|
|
||
| class MulSubsIndex: |
There was a problem hiding this comment.
I'm not sure adding that complexity for subs is really good, this is quite complicated
Tweak to substantially improve CPML-like operator compilation times on PRO backends.
Composite subs keys that are all products used to go through SymPy's
subs, i.e. one full traversal per key.MulSubsIndexfiles each key under one of its factors, walks the expression once, and turns sub-multiset matches into a single compounduxreplacerule. Where SymPy could still rewrite a product the multiset test rejects (powers, differing coefficients), or where keys overlap or chain, it falls back toexpr.subs.Previously, every
Mulkey meant a full sympy subs pass over the expression, so the cost was keys × nodes.MulSubsIndexreplaces that with one pass:Mulkey is filed under the base of one of its factors, preferably an Indexed. Its factor multiset is stored with it, e.g.{w[i0]: 1, p[x+3]: 1}.Mulnode, only the keys filed under that node's own factors are candidates. Most nodes have none, so they cost nothing.Counter<=). For example,a*bmatchesa*b*c, leavingc.uxreplacerule,{a*b*c: {a: value, b: None}}, so the result isvalue*c, built without re-evaluation.(a**2*b**2, 1/(a*b))or a different coefficient;Note that this is completely cooked by Claude in its first iteration and will need substantial review and revision before it is ready for merge.