[SciPy-user] fromfile, item, what other output than stdout / stderr is used ?
Pauli Virtanen
pav at iki.fi
Mon May 11 02:32:12 EDT 2009
Sun, 10 May 2009 12:02:24 +0200, Stef Mientki kirjoitti:
> I'm using "fromfile" to read data from a file generated by another
> program. The data is read on the same operating system as where the file
> was created. I use on several locations, at the procedure seems to run
> very well, but ... ... when run the program from the normal window
> command box, I get an error message:
> "40 items requested but only 10 read"
This is probably because fromfile prints to the C stdio stream. The
correct fix is to make it raise warnings or exceptions instead.
Fromstring raises "ValueError: string is smaller than requested size" if
the string is too short to contain the requested data. Should fromfile do
the same, or do we want to just raise a warning and return fewer items?
Or maybe only return fewer items, without a warning?
[clip]
> Well it must be a byte I guess,
> because if I use bytes as the count, the program is working well, but I
> get the above error message in the windows command window. If I use the
> integer count, the program crashes almost immediately, and thereby I can
> see sometimes the follwing error messages:
> 16 items requested but only 10 read
> 12 items requested but only 0 read
> ....
> self.data = fromfile ( self.Data_File, dtype=int ,count=new_bytes )
> MemoryError
> Fatal Python error: (pygame parachute) Segmentation Fault
What version of Numpy is this? IIRC, there was a some bug that caused
fromfile to crash earlier, but that was fixed.
--
Pauli Virtanen
More information about the SciPy-User
mailing list