jverzani / SymPyCore.jl

Package to help connect Julia with the SymPy library of Python
https://jverzani.github.io/SymPyCore.jl/
MIT License
4 stars 5 forks source link

possible roundtrip; take on TermInterface dependency #75

Open jverzani opened 2 months ago

jverzani commented 2 months ago

Adds a TermInterface dependency, not an extension

Offers a few possible means to roundtrip from, say SymbolicUtils to/from SymPy. This is suggested in https://github.com/JuliaSymbolics/Symbolics.jl/issues/1223

The main issue is roundtripping between symbolic variables and symbolic numbers.

The xchange style requires the user to create pairs of variables and these are exchanged.

The exchange style requires the package developer to define some methods. For SymbolicUtils this is done through an extension.

For this style, the roundtrip process would look something like

import SymPy, SymbolicUtils
import SymPy.SymPyCore: exchange
T,S = SymbolicUtils.Sym, SymPy.SymPyCore.Sym
SymbolicUtils.@syms x
ex = x^2 + 2 # some expression
ex1 = exchange(S, ex)
exchange(T, ex1)