On Fri, 1 May 2020 at 23:59, David Bailey <d...@dbailey.co.uk> wrote:
>
> On 01/05/2020 23:44, Oscar Benjamin wrote:
>
> On Fri, 1 May 2020 at 12:09, David Bailey <d...@dbailey.co.uk> wrote:
>
> On 01/05/2020 00:32, Oscar Benjamin wrote:
>
> Hi Aaron,
>
> Yes, if we had Equation we should disallow its use in an expression. I
> don't see any situation where it would make sense. We would need a
> clear distinction between Equation and Equality as well as methods to
> convert between them.
>
> 1. Equality is a Boolean
> 2. Equation is Basic
> 3. Neither is Expr
> 4. You can use `.as_Boolean/.as_Equation` or something to convert between
> 5. Equation should be used instead of Equality for e.g. passing
> equations to solve/dsolve and for returning solutions.
> 6. Equation should be invalid in any Boolean context
> 7. Equality should not support any of the arithmetic manipulations
> that Equation does
> 8. Equation should be usable in subs or subseq or something (but
> Equality should not)
> 9. Equation should have a solve method for making something the lhs
> 10. Documentation should find a way of making this understandable...
>
> Hang on, doesn't that exclude the very operations we were just discussing, 
> such as
>
> 3+Equation(a-3,b-3)
>
> That example works fine with Equation:
>
> In [5]: a, b = symbols('a, b')
>
> In [6]: 3+Equation(a-3,b-3)
> Out[6]: a = b
>
> Yes but isn't that inconsistent with your statement "Yes, if we had Equation 
> we should disallow its use in an expression"? Surely the example we are 
> discussing is an Equation embedded in an expression!

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.

--
Oscar

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxQOuE_VKo6DFmVjNMBQ9MbNotvRv8Vif_A2KarhfZNYLA%40mail.gmail.com.

Reply via email to