Re: [sympy] Prevent expression evaluation in repr()/latex()

2019-06-03 Thread Jean ABOU SAMRA
Done!
https://github.com/sympy/sympy/issues/16955 


> Le 3 juin 2019 à 19:39, Aaron Meurer  a écrit :
> 
> There have been bugs in the past where printers evaluate
> evaluate=False expressions. It looks like there is another such bug
> here. Can you open an issue for this?
> 
> Aaron Meurer
> 
> On Mon, Jun 3, 2019 at 9:54 AM Jean ABOU SAMRA  wrote:
>> 
>> Hi,
>> 
>> Le 2 juin 2019 à 21:40, Oscar Benjamin  a écrit :
>> 
>> Hi Jean,
>> 
>> 
>> Thanks for your quick answer.
>> 
>> What version of SymPy are you using?
>> 
>> This seems to work fine on SymPy master and with the most recent version 
>> (1.4):
>> 
>> 
>> I'm also using 1.4.
>> 
>> In [1]: repr(Mul(-1, 2, 5, evaluate=False))
>> Out[1]: '-2*5'
>> 
>> 
>> True, but…
>> 
> repr(Mul(-2, 5, evaluate=False))
>> '-10'
>> 
>> In fact, all the problem lies here:
>> 
> # same...
>> ... srepr(Mul(-1, 2, 5, evaluate=False))
>> 'Mul(Integer(-1), Integer(2), Integer(5))'
> srepr(Mul(-2, 5, evaluate=False))
>> 'Mul(Integer(-1), Integer(2), Integer(5))'
> 
> # but different
>> ... repr(Mul(-1, 2, 5, evaluate=False))
>> '-2*5'
> repr(Mul(-2, 5, evaluate=False)) # Hoops!
>> '-10'
> 
> # even weirder
>> ... init_printing()
> Mul(-1, 2, 5, evaluate=False)
>> -2⋅5
> Mul(-2, 5, evaluate=False) # here all is fine!
>> -2⋅5
>> 
>> 
>> Kind regards,
>> Jean Abou Samra
>> 
>> --
>> 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 post to this group, send email to sympy@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/45D94875-5286-4A9C-B9B2-7812DF70A0B7%40abou-samra.fr.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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 post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAKgW%3D6JAVeHVXxx_VfBuPgxSv4RnKBSnV1vDxHMuo%3DsqwYN1NQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/EE52536A-A863-4513-AE61-B5B3559D349C%40abou-samra.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Prevent expression evaluation in repr()/latex()

2019-06-03 Thread Aaron Meurer
There have been bugs in the past where printers evaluate
evaluate=False expressions. It looks like there is another such bug
here. Can you open an issue for this?

Aaron Meurer

On Mon, Jun 3, 2019 at 9:54 AM Jean ABOU SAMRA  wrote:
>
> Hi,
>
> Le 2 juin 2019 à 21:40, Oscar Benjamin  a écrit :
>
> Hi Jean,
>
>
> Thanks for your quick answer.
>
> What version of SymPy are you using?
>
> This seems to work fine on SymPy master and with the most recent version 
> (1.4):
>
>
> I'm also using 1.4.
>
> In [1]: repr(Mul(-1, 2, 5, evaluate=False))
> Out[1]: '-2*5'
>
>
> True, but…
>
> >>> repr(Mul(-2, 5, evaluate=False))
> '-10'
>
> In fact, all the problem lies here:
>
> >>> # same...
> ... srepr(Mul(-1, 2, 5, evaluate=False))
> 'Mul(Integer(-1), Integer(2), Integer(5))'
> >>> srepr(Mul(-2, 5, evaluate=False))
> 'Mul(Integer(-1), Integer(2), Integer(5))'
> >>>
> >>> # but different
> ... repr(Mul(-1, 2, 5, evaluate=False))
> '-2*5'
> >>> repr(Mul(-2, 5, evaluate=False)) # Hoops!
> '-10'
> >>>
> >>> # even weirder
> ... init_printing()
> >>> Mul(-1, 2, 5, evaluate=False)
> -2⋅5
> >>> Mul(-2, 5, evaluate=False) # here all is fine!
> -2⋅5
>
>
> Kind regards,
> Jean Abou Samra
>
> --
> 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 post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/45D94875-5286-4A9C-B9B2-7812DF70A0B7%40abou-samra.fr.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JAVeHVXxx_VfBuPgxSv4RnKBSnV1vDxHMuo%3DsqwYN1NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Prevent expression evaluation in repr()/latex()

2019-06-03 Thread Jean ABOU SAMRA
Hi,
> Le 2 juin 2019 à 21:40, Oscar Benjamin  a écrit :
> 
> Hi Jean,

Thanks for your quick answer.

> What version of SymPy are you using?
> This seems to work fine on SymPy master and with the most recent version 
> (1.4):

I'm also using 1.4.

> In [1]: repr(Mul(-1, 2, 5, evaluate=False))
> Out[1]: '-2*5'

True, but…

>>> repr(Mul(-2, 5, evaluate=False))
'-10'

In fact, all the problem lies here:

>>> # same...
... srepr(Mul(-1, 2, 5, evaluate=False))
'Mul(Integer(-1), Integer(2), Integer(5))'
>>> srepr(Mul(-2, 5, evaluate=False))
'Mul(Integer(-1), Integer(2), Integer(5))'
>>> 
>>> # but different
... repr(Mul(-1, 2, 5, evaluate=False))
'-2*5'
>>> repr(Mul(-2, 5, evaluate=False)) # Hoops!
'-10'
>>> 
>>> # even weirder
... init_printing()
>>> Mul(-1, 2, 5, evaluate=False)
-2⋅5
>>> Mul(-2, 5, evaluate=False) # here all is fine!
-2⋅5


Kind regards,
Jean Abou Samra

-- 
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 post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/45D94875-5286-4A9C-B9B2-7812DF70A0B7%40abou-samra.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Prevent expression evaluation in repr()/latex()

2019-06-02 Thread Oscar Benjamin
Hi Jean,

What version of SymPy are you using?

This seems to work fine on SymPy master and with the most recent version (1.4):

In [1]: repr(Mul(-1, 2, 5, evaluate=False))
Out[1]: '-2*5'

--
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 post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxSmSu%2BFXcr5k7hiqgNuPtfaQNjxF56AO2JkfhEevWsnJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Prevent expression evaluation in repr()/latex()

2019-06-02 Thread ABOU SAMRA Jean
Hello everyone,

I am trying to use SymPy for a mathematical projet, where I need 
expressions to be evaluated step-by-step.
Until now, I have always used, for example, sympify("2+2", evaluate=False) 
and all was fine.

But now I am trying to reconstruct an expression from another object that I 
have created and I sometimes get in trouble with the way the `minus` is 
handled. Let me give an example:

Python 3.8.0a2 (v3.8.0a2:23f4589b4b, Feb 25 2019, 10:59:08) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> from sympy.abc import *
>>> 
>>> e1 = Mul(Integer(2), Integer(5), evaluate=False)
>>> e1 # all fine here
2*5
>>> print(srepr(e1)) # what I expected
Mul(Integer(2), Integer(5))
>>> 
>>> e2 = Mul(Integer(-2), Integer(5), evaluate=False) # now with -2 instead 
of 2
>>> e2 # Hoops!
-10
>>> 
>>> # yet e2 has not been evaluated to Integer(-10) but its repr() above is 
wrong
>>> print(srepr(e2))
Mul(Integer(-1), Integer(2), Integer(5))
>>> # I'm trying to use expressions in LaTeX documents and there our e2 is 
still wrong.
... latex(e2)
'- 10'

I'm quite surprised that Mul(Integer(-1), Integer(2), Integer(5))  becomes 
"-10" when passed through repr(). This is even more surprising:

>>> init_printing()
>>> e2
-2⋅5

How can I prevent the expression to be represented by repr()/latex() in a 
single integer but keep the -2*5 form?

Many thanks for your help.
Regards,
Jean Abou Samra.

-- 
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 post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/9def856d-48c4-4c3e-86d2-e9d9868e6535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.