[NumPy-Tickets] [NumPy] #1793: genfromtxt should probably return an empty array if there is no data.

NumPy Trac numpy-tickets@scipy....
Fri Aug 5 10:13:35 CDT 2011


#1793: genfromtxt should probably return an empty array if there is no data.
------------------------+---------------------------------------------------
  Reporter:  charris    |       Owner:  somebody
      Type:  defect     |      Status:  reopened
  Priority:  normal     |   Milestone:  2.0.0   
 Component:  numpy.lib  |     Version:  devel   
Resolution:             |    Keywords:          
------------------------+---------------------------------------------------
Changes (by derek):

  * status:  closed => reopened
  * resolution:  fixed =>


Comment:

 {{{first_line = ''}}} raises an error with Python3 due to the usual string
 vs. bytes mess:

 {{{
 ERROR: Test that an empty file raises the proper warning.
 ----------------------------------------------------------------------
 Traceback (most recent call last):
 File "/Users/derek/lib/python3.2/site-
 packages/numpy/lib/tests/test_io.py", line 966, in test_empty_file
 test = np.genfromtxt(data)
 File "/Users/derek/lib/python3.2/site-packages/numpy/lib/npyio.py", line
 1498, in genfromtxt
 values = split_line(line)
 File "/Users/derek/lib/python3.2/site-packages/numpy/lib/_iotools.py",
 line 206, in _delimited_splitter
 line = line.split(self.comments)[0].strip(asbytes(" \r\n"))
 TypeError: Can't convert 'bytes' object to str implicitly
 }}}

 Tested the attached fix on python2.5 + 2.7 as well; also added an
 appropriate warning to loadtxt().

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1793#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list