Hi, On 2 October 2014 15:02, Christophe Bal <[email protected]> wrote: > Hello. > > For me the fact that 1/3 == S(1)/3 has value True sounds like a bug > because 1/3 is a float, and S(1)/3 a rational.>
Because 1/3 == S(1)/3 is equivalent to Float(1/3) == S(1)/3 and apparently __eq__ prefers Float comparison instead of Rational, so you get True. I think there are some reasons why this works this way, but indeed it seems wrong. Mateusz > Christophe BAL > > === PYTHON === > > from sympy import * > > a = 1/3 > b = S(1)/3 > > print(a) > print(b) > > print(a == b) > print(type(a)) > print(type(b)) > > --- OUTPUT --- > > 0.3333333333333333 > 1/3 > True > <class 'float'> > <class 'sympy.core.numbers.Rational'> > > -- > 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 post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CAAb4jGm%3DNV4uO9xdSqLGx1ou5AzETbwc_KdYYdOt2bgaRWKywg%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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAGBZUCY8H22dAA50LbH%3DXWbWdcLqdL9MG96XBQbMjxfeU4EoVQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
