inducer / pymbolic

A simple package to do symbolic math (focus on code gen and DSLs)
http://mathema.tician.de/software/pymbolic
Other
106 stars 25 forks source link

Symengine conversion fails due to potentially spurious isinstance check #53

Closed gkaissis closed 3 years ago

gkaissis commented 3 years ago

When trying to convert a pymbolic expression containing a call to exp (-> Call(Lookup(math), exp)), this line gets called which checks if the Lookup is a prim.Variable. From my limited understanding this will always fail and crash because the Lookup is a Lookup type and not a Variable. Indeed, skipping this check converts normally both to symengine and to sympy. Is this intentional? Has this something to do with the context that should be passed to the SymEngine mapper?

Thank you!

inducer commented 3 years ago

The code you point to is more geared towards converting functions encoded as Call(Variable("exp"), ...), i.e. not as a dotted name, but just as a bare identifier. If you'd like to change that behavior, you can simply inherit from the mapper and override it to your heart's content.

gkaissis commented 3 years ago

Thanks so much!