Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 2224 by [email protected]: Number('5').__class__ == Real
http://code.google.com/p/sympy/issues/detail?id=2224
Hi everyone,
First bug report and proposed solution. Be gentle y'all.
Currently the following is standard functionality of the Number constructor
Number( 5 ).__class__ == Integer
Number( 5,3 ).__class__ == Rational #signifies 5/3
Number( 5.25242 ).__class__ == Real
Number( '5' ).__class__ == Real
Number( '5/3' ).__class__ == Real
Number( '5.25242' ).__class__ == Real
What is the desired result here?
Currently if the Number constructor receives a string as input this string
is passed immediately to the Real constructor.
Number(str) => Real(str)
I would propose to try to pass it first to Integer.__new__, then try to
pass it to Rational.__new__, and then if both fail to pass it to
Real.__new__ .
Number(str) => try(Integer(str)) => try(Rational(str)) => Real(str)
However, it appears that Rational.__new__ can handle pretty much any
string. I.e. '5.25242' => 525242/100000 which might also be unwanted
behavior.
It's certainly possible to code up more intuitive behavior. What's best
here?
GSoC disclaimer: This is a super-simplistic change. I'll look around for
some other bug to fix after this. I just wanted to go through this process
once with minimal complexity first.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.