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

Christopher Barker Chris.Barker at noaa.gov
Fri May 4 12:44:02 EDT 2007


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.

Indeed, the Python built-in "float" relies on libc too, and on OS-X 
(glibc), I get:

 >>> float("inf")
inf

On Windows (standard python.org build, compiled with MSC), I get

ValueError: invalid literal for float(): inf

"Inf" gives me the same thing.

It's too bad that C isn't just a little bit more standardized!

In short, I don't know that this is a bug. It is a missing feature, but 
It may be hard to get someone to write the code to account for the 
limited fscanf() in fromfile().

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list