On Mon, Mar 21, 2011 at 15:11, Benjamin Root <ben.root@ou.edu> wrote:
> Came across an odd behavior with a numpy array of datetimes:
>>>>> import numpy as np
>>>> from datetime import datetime
>>>> a = np.empty((9, 20), dtype=datetime)
>>>> a.fill(datetime.now())
>> This works:
>>>> a.min()
> datetime.datetime(2011, 3, 21, 15, 5, 10, 990733)
>> but, this fails:
>>>> np.argmin(a)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/bvr/Programs/numpy/numpy/core/fromnumeric.py", line 754, in
> argmin
> return argmin(axis)
> TypeError: unsupported operand type(s) for -: 'int' and 'datetime.datetime'
>> Is this a bug, or am I just doing datetimes wrong?
Heh. x.argmin() is implemented as (0-x).argmax(). It should probably
just be implemented.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco