[NumPy-Tickets] [NumPy] #1373: mvoid.__str__ fails with python2.4

NumPy Trac numpy-tickets@scipy....
Mon Jan 25 09:33:08 CST 2010


#1373: mvoid.__str__ fails with python2.4
------------------------+---------------------------------------------------
 Reporter:  NeilMuller  |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  Other       |     Version:  devel   
 Keywords:              |  
------------------------+---------------------------------------------------
 The following code fragment
 {{{
 import numpy as np
 from numpy.ma.core import array, mvoid
 ndtype = [('a', int), ('b', float)]
 a = mvoid(np.array((1.0, 2.0, 3.0, 4.0)), mask=(0, 1), dtype=ndtype)
 str(a)
 }}}

 works fine with python2.5, but fails with python2.4

 {{{
 Traceback (most recent call last):
   File "./demo2.py", line 6, in ?
     str(a)
   File "/home/neil/Trees/Numpy_svn/install2.4/lib/python2.4/site-
 packages/numpy/ma/core.py", line 5470, in __str__
     r = [(str(_), p)[_m] for (_, _m) in zip(self._data.tolist(),
 tuple(m))]
 TypeError: tuple indices must be integers
 }}}

 In 2.4, numpy.bool_ isn't converted to an appropriate type for use as an
 index. The attached patch adds an explicit cast to int to solve this.

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


More information about the NumPy-Tickets mailing list