[Numpy-discussion] annoying numpy string to float conversion behaviour

Torgil Svensson torgil.svensson@gmail....
Mon Jun 25 13:33:17 CDT 2007


On 6/22/07, Robert Kern <robert.kern@gmail.com> wrote:
> Making float types parse/emit standard string
> representations for NaNs and infs could probably go in if you were to provide an
> implementation and work out all of the bugs and cross-platform issues.

The float types already emit string-representation of nan's and inf's
but doesn't know how to  parse them back. This parsing step should be
trivial to implement.

I cannot see any cross-platform issues with this. If the floats aren't
binary compatible across platforms we'll have to face these issues
regardless of the string representation (I think they are, except for
endianess).

If cross-platform issues includes string representation from other
sources than python 3.0, things get trickier. I think that python
should handle it's own string representation, others could always be
handled with sub-classing. At a minimum "float(str(nan))==nan" should
evaluate as True.

//Torgil


More information about the Numpy-discussion mailing list