What is the difference between _coeff_isneg(expr) and expr.could_extract_minus_sign()

14 views
Skip to first unread message

Paul Royik

unread,
Aug 10, 2020, 2:39:57 PM8/10/20
to sympy
Seems like they do the same thing or no?
In printing _coeff_isneg is used, in other packages could_extract_minus_sign.

Oscar Benjamin

unread,
Aug 10, 2020, 6:28:11 PM8/10/20
to sympy
I'm not sure but I think that could_extract_minus_sign is used for
canonicalisation of the sign in an expression:

In [13]: e1 = -((y - x)*z)

In [14]: e2 = ((x - y)*z)

In [15]: e1
Out[15]: -z⋅(-x + y)

In [16]: e2
Out[16]: z⋅(x - y)

In [17]: e1.could_extract_minus_sign()
Out[17]: True

In [18]: e2.could_extract_minus_sign()
Out[18]: False

The idea is that you can check this method and then (possibly) extract
a minus sign in order to place it into a canonical form. The canonical
form is useful because equivalent expressions will then be equal.

I don't know what the _coeff_isneg function is.

On Mon, 10 Aug 2020 at 19:39, Paul Royik <distan...@gmail.com> wrote:
>
> Seems like they do the same thing or no?
> In printing _coeff_isneg is used, in other packages could_extract_minus_sign.
>
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b1284654-5ba4-4490-90d0-e535c647d844o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages