You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual output with mpmath 0.5 using python 2.5 compiled from release:
>>> a = "2.76"
>>> b = u"2.76"
>>> mpf( a )
mpf('2.7599999999999998')
>>> mpf( b )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/mpmath/mpmath.py", line 146, in
__new__
return +convert_lossless(val)
File "/usr/lib/python2.5/site-packages/mpmath/mpmath.py", line 36, in
convert_lossless
raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from u'2.76'
>>>
What is the expected output? What do you see instead?
Expected behavior is to be identical to python primitives e.g.
>>> float( "2.76" )
2.7599999999999998
>>> float( u"2.76" )
2.7599999999999998
>>>
Original issue reported on code.google.com by jbes...@gmail.com on 19 Dec 2007 at 12:03
The text was updated successfully, but these errors were encountered:
Hi jbester, thanks for the bug report! I've committed a fix and a testcase to
the SVN
repository.
If you need this feature to work and don't want to install the development
version,
you can just edit mpmath.py and change both instances of
isinstance(x, str)
to
isinstance(x, (str, unicode))
Perhaps it'd be better to check for instances of basestring (to support
user-made
string types?)... I'm not sure about that.
Original comment by fredrik....@gmail.com on 19 Dec 2007 at 3:31
>>> Perhaps it'd be better to check for instances of basestring (to support
user-made
string types?)... I'm not sure about that.
Python's existing Decimal class as included in 2.5 uses basestring, however,
that may
run contrary to any compatibility requirements you have. Either solution works
for me :)
Original comment by jbes...@gmail.com on 19 Dec 2007 at 11:41
Original issue reported on code.google.com by
jbes...@gmail.com
on 19 Dec 2007 at 12:03The text was updated successfully, but these errors were encountered: