The example below demonstrates the fact that the datetime64 constructor 
ignores the dtype argument if passed in. Is this conscious design decision or 
a bug/oversight?


In [55]: from datetime import datetime
    ...: d = datetime.now()
    ...: 

In [56]: d
Out[56]: datetime.datetime(2013, 6, 12, 11, 3, 27, 861000)

In [57]: np.datetime64(d)
Out[57]: numpy.datetime64('2013-06-12T12:03:27.861000+0100')

In [58]: np.datetime64(d).dtype
Out[58]: dtype('<M8[us]')

In [59]: np.datetime64(d, dtype='M8[D]')
Out[59]: numpy.datetime64('2013-06-12T12:03:27.861000+0100')

In [60]: np.datetime64(d, dtype='M8[D]').dtype
Out[60]: dtype('<M8[us]')   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ???

In [61]: np.datetime64(d).astype('M8[D]')
Out[61]: numpy.datetime64('2013-06-12')


Thanks,
Dave

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to