[NumPy-Tickets] [NumPy] #1912: datetime and record arrays/masked arrays

NumPy Trac numpy-tickets@scipy....
Mon Jul 18 16:59:55 CDT 2011

#1912: datetime and record arrays/masked arrays
 Reporter:  cjordansquire  |       Owner:  somebody   
     Type:  defect         |      Status:  new        
 Priority:  normal         |   Milestone:  Unscheduled
Component:  Other          |     Version:  devel      
 Keywords:                 |  
 I'm using the 2.0.0 development version of numpy on ububtu 10.10 .

 When string arguments for the dtype are given for a record array, and one
 of the individual dtypes is datetime64[D], the day part is lost and the
 datetime become generic. This makes it impossible to assign anything to

 For example, look at
 np.zeros(4, dtype = ','.join(['datetime64[D]', 'i4']))

 This gives an array with dtype dtype=[('f0', <M8), ('f1', '<i4')], where
 the <M8 should be <M8[D].

 A different bug happens when putting datetimes into masked arrays. For
 np.ma.zeros(4,dtype= 'datetime64[D],i4')
 gives a ValueError: mismatch in size of old and new data-descriptor with

 /home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in
 __call__(self, a, *args, **params)
    7142             _extras[p] = params.pop(p)
    7143         # Get the result

 -> 7144         result = self._func.__call__(a, *args,
    7145         if "fill_value" in common_params:
    7146             result.fill_value = _extras.get("fill_value", None)

 /home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in
 __array_finalize__(self, obj)
    2794         if self.dtype.names:
    2795             if self._fill_value is None:
 -> 2796                 self._fill_value = _check_fill_value(None,
    2797         return

 /home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in
 _check_fill_value(fill_value, ndtype)
     392         if fields:
     393             descr = ndtype.descr
 --> 394             fill_value =
     395                                   dtype=ndtype,)
     396         else:

 /home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in
     361         else:
 --> 362
     363     return tuple(deflist)

 ValueError: mismatch in size of old and new data-descriptor

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

More information about the NumPy-Tickets mailing list