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

Charles R Harris charlesr.harris at gmail.com
Thu Apr 10 20:31:47 EDT 2008


On Fri, Apr 4, 2008 at 1:47 PM, Robert Kern <robert.kern at gmail.com> 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.
>
> That said, str(float_numpy_scalar) really should have the same rules
> as str(some_python_float).
>

For all different precisions? And what should the rules be. I note that
numpy doesn't distinguish between repr and str, maybe we could specify
different behavior for the two.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080410/940171c3/attachment.html>


More information about the NumPy-Discussion mailing list