[Numpy-svn] r3876 - in trunk/numpy: . core/src core/tests

numpy-svn@scip... numpy-svn@scip...
Sat Jun 30 09:42:34 CDT 2007


Author: charris
Date: 2007-06-30 09:42:31 -0500 (Sat, 30 Jun 2007)
New Revision: 3876

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/core/src/_sortmodule.c.src
   trunk/numpy/core/tests/test_regression.py
Log:
Replace <= by < in the insertion sort part of argsort(kind='mergesort')
for strings. Fixes ticket #540.


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2007-06-20 00:30:11 UTC (rev 3875)
+++ trunk/numpy/add_newdocs.py	2007-06-30 14:42:31 UTC (rev 3876)
@@ -367,7 +367,7 @@
     sort order, and so on).  The keys argument must be a sequence of things
     that can be converted to arrays of the same shape.
 
-    :Parameters:
+    Parameters:
 
         a : array type
             Array containing values that the returned indices should sort.
@@ -376,16 +376,16 @@
             Axis to be indirectly sorted. None indicates that the flattened
             array should be used. Default is -1.
 
-    :Returns:
+    Returns:
 
         indices : integer array
             Array of indices that sort the keys along the specified axis. The
             array has the same shape as the keys.
 
-    :SeeAlso:
+    SeeAlso:
 
-      - argsort : indirect sort
-      - sort : inplace sort
+        argsort : indirect sort
+        sort : inplace sort
 
     """)
 

Modified: trunk/numpy/core/src/_sortmodule.c.src
===================================================================
--- trunk/numpy/core/src/_sortmodule.c.src	2007-06-20 00:30:11 UTC (rev 3875)
+++ trunk/numpy/core/src/_sortmodule.c.src	2007-06-30 14:42:31 UTC (rev 3876)
@@ -377,7 +377,7 @@
                         *pi = *pj;
                 }
                 for(pk = pw, pm = pl; pk < pi && pj <= pr; ++pm) {
-                        if (@comp@(v+(*pk)*len,v+(*pj)*len,len)<=0) {
+                        if (@comp@(v+(*pk)*len,v+(*pj)*len,len) <= 0) {
                                 *pm = *pk;
                                 ++pk;
                         }else{
@@ -393,8 +393,8 @@
                 for(pi = pl + 1; pi <= pr; ++pi) {
                         vi = *pi;
                         vp = v + vi*len;
-                        for(pj = pi, pk = pi - 1;                       \
-			    pj > pl && (@comp@(vp, v+(*pk)*len,len)<=0); \
+                        for(pj = pi, pk = pi - 1;                        \
+			    pj > pl && (@comp@(vp, v+(*pk)*len,len) < 0);\
 			    --pj, --pk) {
                                 *pj = *pk;
                         }

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2007-06-20 00:30:11 UTC (rev 3875)
+++ trunk/numpy/core/tests/test_regression.py	2007-06-30 14:42:31 UTC (rev 3876)
@@ -687,5 +687,11 @@
         x = N.random.rand(*(2,)*16)
         y = x.transpose(range(16))
 
+    def check_string_mergesort(self, level=rlevel):
+        """Ticket #540"""
+        x = N.array(['a']*32)
+        assert_array_equal(x.argsort(kind='m'), N.arange(32))
+
+
 if __name__ == "__main__":
     NumpyTest().run()



More information about the Numpy-svn mailing list