[Numpy-discussion] loadtxt broken if file does not end in newline
Christopher Barker
Chris.Barker at noaa.gov
Wed Feb 27 19:31:50 EST 2008
Robert Kern wrote:
> Fixed in r4827.
Thanks Robert. For the record, this is the fixed version:
comment_start = line.find(comments)
if comment_start > 0:
line = line[:comments_start].strip()
else:
line = line.strip()
Just as a matter of interest, why this, rather than line.index()? Are
exceptions slower than an if test?
Also,
I don't see any io tests in:
numpy/lib/tests
Is that where they should be? It seems like a good idea to have a few...
If I did find the time to write some tests -- how does one go about it
for this sort of thing? Do I put a couple sample input files in SVN? Or
does the test code write out the sample files, then read them in to
test? Or maybe do it all in memory with sStringIO or something. Are
there any examples of tests of file reading code that I could borrow from?
thanks,
-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