[Numpy-tickets] [NumPy] #222: rstrip on chararray causes Attribute Error

NumPy numpy-tickets at scipy.net
Wed Aug 2 14:26:56 CDT 2006


#222: rstrip on chararray causes Attribute Error
------------------------+---------------------------------------------------
 Reporter:  chanley     |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  high        |   Milestone:          
Component:  numpy.core  |     Version:          
 Severity:  major       |    Keywords:          
------------------------+---------------------------------------------------
 {{{
 >>> from numpy.core import *
 >>> r = rec.fromrecords([[456,'dbe    ',1.2],[2,'de
 ',1.3]],names='col1,col2,col3')
 >>> r
 recarray([(456, 'dbe    ', 1.2), (2, 'de    ', 1.3)],
       dtype=[('col1', '<i4'), ('col2', '|S7'), ('col3', '<f8')])
 >>> r.field(1)
 chararray([dbe    , de    ],
       dtype='|S7')
 >>> a = r.field(1)
 >>> a
 chararray([dbe    , de    ],
       dtype='|S7')
 >>> b = a.rstrip()
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/data/sparty1/dev/site-
 packages/lib/python/numpy/core/defchararray.py", line 263, in rstrip
     return self._generalmethod('rstrip', broadcast(self, chars))
   File "/data/sparty1/dev/site-
 packages/lib/python/numpy/core/defchararray.py", line 138, in
 _generalmethod
     if chk.dtype is object_ and chk.item() is None:
 AttributeError: 'NoneType' object has no attribute 'dtype'
 >>>
 }}}

 In numarray, chararrays always truncate trailing whitespace.  Without the
 ability to strip these trailing blanks pyfits will have problems working
 with numpy.

 Chris

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


More information about the Numpy-tickets mailing list