[SciPy-user] numpy : Fromfile should trigger an exception

Travis Oliphant oliphant.travis at ieee.org
Fri Feb 24 06:51:40 EST 2006


Xavier Gnata wrote:

>Hi,
>
>Trying to read more value than those that are available in a binary
>file, numpy fromfile function prints a warning message but no exception
>is triggered
>
>import numpy
>a=numpy.arange(10)
>a.tofile('toto.dat')
>b = numpy.fromfile('toto.dat',numpy.Int32,11)
>
>shows
>11 items requested but only 10 read
>
>But there is no easy way to know that something went wrong (or I'm
>missing something).
>  
>
This should probably be changed to a true warning so that you can catch 
it if you want to.

-Travis




More information about the SciPy-User mailing list