On numpy version 1.0, argmax and max give inconsistent results for an array of objects. I've seen this problem in both Python native datetime and mx.DateTime types:

In [22]: print nativeDates
[datetime.datetime(2006, 10, 18, 10, 11, 27), datetime.datetime(2006, 10, 18, 10, 16, 20), datetime.datetime(2006, 10, 18, 10, 21, 23), datetime.datetime(2006, 10, 18, 10, 31, 13), datetime.datetime(2006, 10, 18, 10, 39, 49), datetime.datetime(2006, 10, 18, 10, 53, 19), datetime.datetime(2006, 10, 18, 11, 23, 18), datetime.datetime(2006, 10, 18, 17, 18, 43), datetime.datetime(2006, 10, 18, 17, 21, 49), datetime.datetime(2006, 10, 18, 17, 24, 28), datetime.datetime(2006, 10, 18, 17, 28, 29), datetime.datetime(2006, 10, 18, 17, 31, 7), datetime.datetime(2006, 10, 18, 17, 36, 26), datetime.datetime(2006, 10, 19, 10, 17, 45), datetime.datetime(2006, 10, 19, 11, 23, 19), datetime.datetime(2006, 10, 19, 11, 58, 18), datetime.datetime(2006, 10, 19, 10, 27, 40), datetime.datetime(2006, 10, 19, 13, 17, 14), datetime.datetime(2006, 10, 19, 13, 21, 17), datetime.datetime(2006, 10, 19, 13, 23, 52), datetime.datetime(2006, 10, 19, 13, 29, 1)]

In [23]: numpy.argmax(nativeDates)
Out[23]: 0

In [24]: numpy.max(nativeDates)
Out[24]: datetime.datetime(2006, 10, 19, 13, 29, 1)

In [25]: nativeDates[0]
Out[25]: datetime.datetime(2006, 10, 18, 10, 11, 27)

I get the same results if I create an array from the list first:

In [28]: dateArr = numpy.array(nativeDates, dtype=object)

In [29]: print dateArr
[2006-10-18 10:11:27 2006-10-18 10:16:20 2006-10-18 10:21:23
 2006-10-18 10:31:13 2006-10-18 10:39:49 2006-10-18 10:53:19
 2006-10-18 11:23:18 2006-10-18 17:18:43 2006-10-18 17:21:49
 2006-10-18 17:24:28 2006-10-18 17:28:29 2006-10-18 17:31:07
 2006-10-18 17:36:26 2006-10-19 10:17:45 2006-10-19 11:23:19
 2006-10-19 11:58:18 2006-10-19 10:27:40 2006-10-19 13:17:14
 2006-10-19 13:21:17 2006-10-19 13:23:52 2006-10-19 13:29:01]

In [30]: numpy.argmax(dateArr)
Out[30]: 0

In [31]: numpy.max(dateArr)
Out[31]: datetime.datetime(2006, 10, 19, 13, 29, 1)

In [32]: dateArr[0]
Out[32]: datetime.datetime(2006, 10, 18, 10, 11, 27)

My guess is that it's related to some underlying memory layout; I've gotten different results when running this.

Jonathan

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to