Jason K. Moore

Results 1408 comments of Jason K. Moore

I thought this would work, but it doesn't: ``` In [1]: import sympy as sm In [2]: t = sm.symbols("t") In [3]: x = sm.Function("x")(t) In [4]: xd = x.diff(t)...

cse is called on the expressions and then the cse results are passed to the printer which runs a preprocessor on the results that do the dummifying. I'm guessing those...

The dummy replacement works recursively already. Maybe just look into having the preprocessor apply the dummy subs to all of the cse output.

Actually this code looks like the preprocessor is applied to all outputs of cse: https://github.com/sympy/sympy/blob/master/sympy/utilities/lambdify.py#L1133-L1140

It looks like in the CSE process, which happens first, the argument of the derivative gets swapped out: ``` ipdb> expr [x0 + Derivative(x0, t), x(t)] ``` This would then...

One option would be a flag to cse() to have it skip `Derivative(x, t)` type terms.

Maybe a pre and post optimization could be used for cse, something like: ``` In [27]: def pre(expr): return expr.xreplace({xd: sm.Symbol('a')}) In [28]: def post(expr): return expr.xreplace({sm.Symbol('a'): xd}) In [29]:...

> It would work to, but what are the advantages to this compared to the flag possibility?(since with this possibility, we would go trhough the expression twice and still ignore...

This seems to be fixed in master: ``` moorepants@nandi:sympy(master)$ ipython Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0] Type 'copyright', 'credits' or 'license' for...

test script: ```python import sympy as sm t = sm.symbols("t") x = sm.Function("x")(t) xd = x.diff(t) print(sm.lambdify((xd, x), xd + x)(1, 1)) print(sm.lambdify((xd, x), xd, cse=True)(1, 1)) print(sm.lambdify((xd, x), xd...