[NumPy-Tickets] [NumPy] #2116: MaskedArray record: TypeError: len() of unsized object

NumPy Trac numpy-tickets@scipy....
Thu Apr 26 01:50:37 CDT 2012

#2116: MaskedArray record: TypeError: len() of unsized object
 Reporter:  mwtoews   |       Owner:  pierregm   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  numpy.ma  |     Version:  1.6.1      
 Keywords:            |  
 I'm getting a inconsistent error while trying to get the length of a
 record from a masked array, but only when the mask is enabled. See the
 import numpy as np

 my_dtype = [('a','i'),('b','f')]
 mar = np.ma.zeros(5, my_dtype)

 # Length of the first record; no error raised
 assert len(mar[0]) == 2

 # Change mask for one of the fields
 print(mar[0])          # (0, 0.0)
 mar.mask[0][0] = True
 print(mar[0])          # (--, 0.0)

 # Repeat same command as above to reveal this bug
 assert len(mar[0]) == 2
 Raises the error:
 Traceback (most recent call last):
   File "<interactive input>", line 1, in <module>
 TypeError: len() of unsized object

 I am using !NumPy version 1.6.1 obtained from
 http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy and the version of Python
 is 2.5.1 [MSC v.1310 32 bit (Intel)].

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

More information about the NumPy-Tickets mailing list