[NumPy-Tickets] [NumPy] #1998: loadtxt should give line numbers of problems

NumPy Trac numpy-tickets@scipy....
Thu Dec 15 12:23:28 CST 2011

#1998: loadtxt should give line numbers of problems
 Reporter:  samtygier  |       Owner:  somebody   
     Type:  defect     |      Status:  new        
 Priority:  normal     |   Milestone:  Unscheduled
Component:  Other      |     Version:  1.6.0      
 Keywords:             |  
 currently input like
 1 2 3
 4 5 6
 will cause loadtxt to give the following error
 Traceback (most recent call last):
   File "./np_lt.py", line 5, in <module>
   File "/usr/lib/python2.7/site-packages/numpy/lib/npyio.py", line 804, in
     X = np.array(X, dtype)
 ValueError: setting an array element with a sequence.

 This would be far more useful, if it contained some information about
 where the problem was.

 This is similar to the bug #1212 , but for the loadtxt function.

 I attach a patch that gives the following message:
 ValueError: Wrong number of columns at line 3
 it also provides a test that the input raises the correct error.
 Inconveniently it is the same error type as before, so the test is not
 very useful. However I thing ValueError is probably the most appropriate
 in this case. Maybe there is a way to check the exception message.

Ticket URL: <http://projects.scipy.org/numpy/ticket/1998>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list