[NumPy-Tickets] [NumPy] #1927: datetime masked array and record array repr bugs

NumPy Trac numpy-tickets@scipy....
Mon Aug 8 15:48:38 CDT 2011

#1927: datetime masked array and record array repr bugs
 Reporter:  cjordansquire  |       Owner:  somebody   
     Type:  defect         |      Status:  new        
 Priority:  normal         |   Milestone:  Unscheduled
Component:  Other          |     Version:  devel      
 Keywords:                 |  
 I have a record array with the following elements

 np.array([(datetime.date(1991, 11,3), np.datetime64('NaT')),
 (np.datetime64('NaT'),datetime.date(2001, 3, 10))],
 dtype=[('date1', '<M8[D]'), ('date2', '<M8[D]')])

 np.array_repr of the above array gives

 array([(datetime.date(1991, 11, 3), None),
        (None, datetime.date(2001, 3, 10))],
       dtype=[('date1', '<M8[D]'), ('date2', '<M8[D]')])

 So the np.datetime64('NaT') are printed as None. This certainly isn't
 correct for a repr.

 Additionally, for a masked record array the repr drops the 'datetime.date'
 if there is a missing entry in the row. For example, if you let z be the
 array given above, and then do

 w = np.ma.array(z)
 w.mask[0] = (False, True)

 Then np.array_repr(w) will yield

 "MaskedArray([(1991-11-03, --), (None, datetime.date(2001, 3, 10))], \n
 dtype=[('date1', '<M8[D]'), ('date2', '<M8[D]')])"

 This is wrong because it gives 1991-11-03 instead of datetime.date(1991,
 11, 3) in the [0,0] entry.

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

More information about the NumPy-Tickets mailing list