On 02/05/2020 00:07, Oscar Benjamin wrote:
There is a difference between having an object as part of an
expression and having an object that supports arithmetic operations.
Objects of type Expr support arithmetic operations and by default the
result creates an expression involving the original object so e.g. a+b
becomes Add(a, b). That's what happens with Eq in sympy 1.5 because in
1.5 Eq is a subclass of Expr so Eq(a, b)+1 becomes Add(Eq(a, b), 1)
which is nonsensical. In 1.6 Eq does not subclass Expr and also Expr
is fussier about what types it can interact with through arithmetic
operations so this gives an error.
The point of Equation is that it can support some arithmetic
operations and the result will always be an Equation and never an
expression. It should never be a part of an expression though so e.g.
Add(Equation(x, y), z) is an error because Add is of type Expr and its
arguments need to be of type Expr but Equation is not of type Expr.
That does not preclude Equation(x,y)+1 giving an Equation though.
Doesn't that feel a bit arbitrary, I mean you seem to be saying saying that
Equation(a+k,b+k)-k
where a,b, and k are SymPy symbols
would fail?
If that is the case, the new ability to add/subtract things from
Equations doesn't seem that powerful.
David
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/782e6472-bbe5-3a4d-9222-e6968014f118%40dbailey.co.uk.