symengine.py
symengine.py copied to clipboard
Strange args for Piecewise
A Piecewise does not give a tuple of tuple as args. This makes it incompatible with sympy.
expr = symengine.Piecewise((symengine.Symbol("x"), symengine.Symbol("y") > 0), (symengine.Symbol("k"), symengine.Symbol("w") > 0))
print(symengine.unicode(expr))
⎧x if 0 < y
⎨
⎩k if 0 < w
expr.args
>>> (x, 0 < y, k, 0 < w)
import sympy
sympy.sympify(expr).args
>>> ((x, y > 0), (k, w > 0))
After pondering this I am now thinking that what symengine is doing is more consistent across all functions. sympy is actually returning a separate pair object which is quite different from any other args. I think we should keep the current behaviour for consistency. Any other thoughts?