symengine.py icon indicating copy to clipboard operation
symengine.py copied to clipboard

Strange args for Piecewise

Open rikardn opened this issue 2 years ago • 1 comments

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))

rikardn avatar Jan 29 '24 08:01 rikardn

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?

rikardn avatar Feb 15 '24 13:02 rikardn