[Numpy-discussion] Difference in the number of elements in a fromfile() between Windows and Linux

Robert Kern robert.kern at gmail.com
Fri May 4 18:43:00 EDT 2007


Stefan van der Walt wrote:
> On Fri, May 04, 2007 at 09:44:02AM -0700, Christopher Barker wrote:
>> Matthieu Brucher wrote:
>>> Example of the first line of my data file :
>>> 0.0 inf 13.9040914426 14.7406669444 inf 4.41783247603 inf inf 
>>> 6.05071515635 inf inf inf 15.6925185021 inf inf inf inf inf inf inf
>> I'm pretty sure fromfile() is using the standard C fscanf(). That means 
>> that whether in understands "inf" depends on the C lib. I'm guessing 
>> that the MS libc doesn't understand the same spelling of "inf" that the 
>> gcc one does. There may indeed be no literal for the IEEE Inf.
> 
> It would be interesting to see how Inf and NaN (vs. inf and nan) are
> interpreted under Windows.

I'm pretty sure that they are also rejected. "1.#INF" and "1.#QNAN" might be
accepted though since that's what ftoa() gives for those quantities.

> Are there any free fscanf implementations out there that we can
> include with numpy?

This might be easy enough to adapt:

  http://www.python.org/ftp/python/contrib-09-Dec-1999/Misc/sscanfmodule.c.Z

-- 
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