[Numpy-discussion] problem with float64's str()
Stéfan van der Walt
Fri Apr 4 05:14:06 CDT 2008
On 03/04/2008, Will Lee <email@example.com> wrote:
> I seem to have problem with floating point printing with the latest numpy,
> python 2.5.2, gcc 4.1.4, and 64-bit linux:
> In : print str(0.0012)
> In : a = numpy.array([0.0012])
> In : print str(a)
> In : print numpy.__version__
> It seems like the str() behavior for float64 in the latest numpy's behavior
> is different than Python's default behavior (and previous numpy's behavior).
> As I have numerous doc tests, this seems to make many of them failed.
> Should the float64's str() behavior be consistent with what's described in
> http://docs.python.org/tut/node16.html? Is there any way
> to get around it so I can get to the default Python behavior?
As a workaround, you can simply remove 'str' from your print statement:
In : print x
I am not sure why str([x) is equivalent to repr(0.0012).
More information about the Numpy-discussion