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

Travis E. Oliphant oliphant at enthought.com
Fri Apr 4 16:12:40 EDT 2008


Robert Kern wrote:
> On Fri, Apr 4, 2008 at 9:56 AM, Will Lee <lee.will at 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.
>
>   
Well said, Robert.

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

-Travis







More information about the NumPy-Discussion mailing list