[Numpy-svn] r3486 - in trunk/numpy: lib oldnumeric

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Dec 14 03:54:07 CST 2006


Author: oliphant
Date: 2006-12-14 03:54:03 -0600 (Thu, 14 Dec 2006)
New Revision: 3486

Modified:
   trunk/numpy/lib/function_base.py
   trunk/numpy/oldnumeric/compat.py
Log:
Fix typo in oldnumeric and add Rick White's improvement to histogram for large arrays.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-12-13 05:16:09 UTC (rev 3485)
+++ trunk/numpy/lib/function_base.py	2006-12-14 09:54:03 UTC (rev 3486)
@@ -93,7 +93,11 @@
             mx += 0.5
         bins = linspace(mn, mx, bins, endpoint=False)
 
-    n = sort(a).searchsorted(bins)
+    # best block size probably depends on processor cache size
+    block = 65536
+    n = sort(a[:block]).searchsorted(bins)
+    for i in xrange(block, a.size, block):
+        n += sort(a[i:i+block]).searchsorted(bins)
     n = concatenate([n, [len(a)]])
     n = n[1:]-n[:-1]
 

Modified: trunk/numpy/oldnumeric/compat.py
===================================================================
--- trunk/numpy/oldnumeric/compat.py	2006-12-13 05:16:09 UTC (rev 3485)
+++ trunk/numpy/oldnumeric/compat.py	2006-12-14 09:54:03 UTC (rev 3486)
@@ -56,7 +56,7 @@
         x = mu.fromstring(thestr, typecode)
     x.shape = shape
     if LittleEndian != Endian:
-        return x.byteswap(TRUE)
+        return x.byteswap(True)
     else:
         return x
 



More information about the Numpy-svn mailing list