[Numpy-discussion] problem with float64's str()

Robert Kern robert.kern@gmail....
Fri Apr 4 14:47:46 CDT 2008


On Fri, Apr 4, 2008 at 9:56 AM, Will Lee <lee.will@gmail.com> wrote:
> I understand the implication for the floating point comparison and the need
> for allclose.  However, I think in a doctest context, this behavior makes
> the doc much harder to read.

Tabling the issue of the fact that we changed behavior for a moment,
this is a fundamental problem with using doctests as unit tests for
numerical code. The floating point results that you get *will* be
different on different machines, but the code will still be correct.
Using allclose() and similar techniques are the best tools available
(although they still suck). Relying on visual representations of these
results is simply an untenable strategy. Note that the string
representation of NaNs and Infs are completely different across
platforms.

That said, str(float_numpy_scalar) really should have the same rules
as str(some_python_float).

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list