[Numpy-tickets] [NumPy] #297: Nested sequences with different lengths issues

NumPy numpy-tickets at scipy.net
Wed Sep 27 12:41:17 CDT 2006


#297: Nested sequences with different lengths issues
------------------------+---------------------------------------------------
 Reporter:  faltet      |        Owner:  somebody   
     Type:  defect      |       Status:  closed     
 Priority:  normal      |    Milestone:  1.0 Release
Component:  numpy.core  |      Version:  devel      
 Severity:  minor       |   Resolution:  fixed      
 Keywords:              |  
------------------------+---------------------------------------------------
Changes (by oliphant):

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

Comment:

 I've changed string and unicode getitems so that sequences are not allowed
 (unless they are strings or unicode sequences.  Previously str(obj) and
 unicode(obj) were being called on the object being set.  If this was a
 sequence, then the stringified sequence was used without difficulty.

 The array from sequence code basically looks like

 # get shape and size from sequence (by looking at the first element in
 each depth)

 # for k in range(shape[0]):
 #      new[k] = obj[k]
 #

 So, a 1-d loop is used and the setitem is used of new with the getitem of
 obj to construct the result.  If there is a mismatch in the level of
 nesting this is not caught until the attempt at setting doesn't work.

 All error messages have been changed for the problem trying to set an
 array element with a sequence to "setting an array element with a
 sequence".  It is still a type-error.  For strings and unicode arrays,
 strings and unicode "sequences" are of course allowed.

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/297>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list