[Scipy-svn] r3630 - in trunk/scipy: linsolve/umfpack sparse sparse/sparsetools sparse/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Dec 10 18:26:06 EST 2007


Author: wnbell
Date: 2007-12-10 17:25:35 -0600 (Mon, 10 Dec 2007)
New Revision: 3630

Modified:
   trunk/scipy/linsolve/umfpack/umfpack.py
   trunk/scipy/sparse/sparse.py
   trunk/scipy/sparse/sparsetools/sparsetools.i
   trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx
   trunk/scipy/sparse/tests/test_sparse.py
Log:
ensure_sorted_indices -> sort_indices and sorted_indices


Modified: trunk/scipy/linsolve/umfpack/umfpack.py
===================================================================
--- trunk/scipy/linsolve/umfpack/umfpack.py	2007-12-10 22:36:31 UTC (rev 3629)
+++ trunk/scipy/linsolve/umfpack/umfpack.py	2007-12-10 23:25:35 UTC (rev 3630)
@@ -355,7 +355,7 @@
 
         if not assumeSortedIndices:
             # row/column indices cannot be assumed to be sorted
-            mtx.ensure_sorted_indices( inplace = True )
+            mtx.sort_indices()
 
         indx = self._getIndx( mtx )
         if self.isReal:

Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py	2007-12-10 22:36:31 UTC (rev 3629)
+++ trunk/scipy/sparse/sparse.py	2007-12-10 23:25:35 UTC (rev 3630)
@@ -934,15 +934,36 @@
     def conj(self, copy=False):
         return self._with_data(self.data.conj(),copy=copy)
 
-    def _ensure_sorted_indices(self, shape0, shape1, inplace=False):
-        """Return a copy of this matrix where the row indices are sorted
+    def sorted_indices(self):
+        """Return a copy of this matrix with sorted indices
         """
+        A = self.copy()
+        A.sort_indices()
+        return A
+
+        # an alternative that has linear complexity is the following
+        # typically the previous option is faster
+        #return self._toother()._toother()
+
+    def sort_indices(self):
+        """Sort the indices of this matrix *in place*
+        """
+        fn = getattr(sparsetools,'sort_' + self.format + '_indices')
+
+        M,N = self.shape
+        fn( M, N, self.indptr, self.indices, self.data)
+
+    def ensure_sorted_indices(self, inplace=False):
+        """Return a copy of this matrix where the column indices are sorted
+        """
+        warnings.warn('ensure_sorted_indices is deprecated, ' \
+                      'use sorted_indices() or sort_indices() instead', \
+                      DeprecationWarning)
+        
         if inplace:
-            sparsetools.sort_csr_indices(shape0, shape1,
-                                         self.indptr, self.indices,
-                                         self.data )
+            self.sort_indices()
         else:
-            return self._toother()._toother()
+            return self.sorted_indices()
 
     def _get_submatrix( self, shape0, shape1, slice0, slice1 ):
         """Return a submatrix of this matrix (new matrix is created)."""
@@ -1189,11 +1210,6 @@
         self.indices = self.indices[:nnz]
         self.nzmax = nnz
 
-    def ensure_sorted_indices(self, inplace=False):
-        """Return a copy of this matrix where the row indices are sorted
-        """
-        return _cs_matrix._ensure_sorted_indices(self, self.shape[1], self.shape[0], inplace)
-
     def get_submatrix( self, slice0, slice1 ):
         """Return a submatrix of this matrix (new matrix is created).
         Rows and columns can be selected using slice instances, tuples,
@@ -1342,8 +1358,7 @@
     def tolil(self):
         lil = lil_matrix(self.shape,dtype=self.dtype)
      
-        #TODO make this more efficient
-        csr = self.ensure_sorted_indices()
+        csr = self.sorted_indices()
         
         rows,data = lil.rows,lil.data
         ptr,ind,dat = csr.indptr,csr.indices,csr.data
@@ -1419,11 +1434,6 @@
         self.indices = self.indices[:nnz]
         self.nzmax = nnz
 
-    def ensure_sorted_indices(self, inplace=False):
-        """Return a copy of this matrix where the column indices are sorted
-        """
-        return _cs_matrix._ensure_sorted_indices(self, self.shape[0], self.shape[1], inplace)
-
     def get_submatrix( self, slice0, slice1 ):
         """Return a submatrix of this matrix (new matrix is created)..
         Rows and columns can be selected using slice instances, tuples,

Modified: trunk/scipy/sparse/sparsetools/sparsetools.i
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools.i	2007-12-10 22:36:31 UTC (rev 3629)
+++ trunk/scipy/sparse/sparsetools/sparsetools.i	2007-12-10 23:25:35 UTC (rev 3630)
@@ -90,6 +90,7 @@
 %define I_INPLACE_ARRAY1( ctype )
 %apply ctype * INPLACE_ARRAY {
   ctype Ap [ ],
+  ctype Ai [ ],
   ctype Aj [ ],
   ctype Bp [ ],
   ctype Bi [ ],

Modified: trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx	2007-12-10 22:36:31 UTC (rev 3629)
+++ trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx	2007-12-10 23:25:35 UTC (rev 3630)
@@ -2478,18 +2478,17 @@
 /* -------- TYPES TABLE (BEGIN) -------- */
 
 #define SWIGTYPE_p_char swig_types[0]
-#define SWIGTYPE_p_int swig_types[1]
-#define SWIGTYPE_p_std__vectorTdouble_t swig_types[2]
-#define SWIGTYPE_p_std__vectorTfloat_t swig_types[3]
-#define SWIGTYPE_p_std__vectorTint_t swig_types[4]
-#define SWIGTYPE_p_std__vectorTlong_long_t swig_types[5]
-#define SWIGTYPE_p_std__vectorTnpy_cdouble_wrapper_t swig_types[6]
-#define SWIGTYPE_p_std__vectorTnpy_cfloat_wrapper_t swig_types[7]
-#define SWIGTYPE_p_std__vectorTshort_t swig_types[8]
-#define SWIGTYPE_p_std__vectorTsigned_char_t swig_types[9]
-#define SWIGTYPE_p_std__vectorTunsigned_char_t swig_types[10]
-static swig_type_info *swig_types[12];
-static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
+#define SWIGTYPE_p_std__vectorTdouble_t swig_types[1]
+#define SWIGTYPE_p_std__vectorTfloat_t swig_types[2]
+#define SWIGTYPE_p_std__vectorTint_t swig_types[3]
+#define SWIGTYPE_p_std__vectorTlong_long_t swig_types[4]
+#define SWIGTYPE_p_std__vectorTnpy_cdouble_wrapper_t swig_types[5]
+#define SWIGTYPE_p_std__vectorTnpy_cfloat_wrapper_t swig_types[6]
+#define SWIGTYPE_p_std__vectorTshort_t swig_types[7]
+#define SWIGTYPE_p_std__vectorTsigned_char_t swig_types[8]
+#define SWIGTYPE_p_std__vectorTunsigned_char_t swig_types[9]
+static swig_type_info *swig_types[11];
+static swig_module_info swig_module = {swig_types, 10, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -39374,8 +39373,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39404,12 +39402,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_BYTE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (signed char*) array_data(temp5);
@@ -39441,8 +39439,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39471,12 +39468,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_UBYTE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (unsigned char*) array_data(temp5);
@@ -39508,8 +39505,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39538,12 +39534,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_SHORT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (short*) array_data(temp5);
@@ -39575,8 +39571,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39605,12 +39600,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_INT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (int*) array_data(temp5);
@@ -39642,8 +39637,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39672,12 +39666,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_LONGLONG);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (long long*) array_data(temp5);
@@ -39709,8 +39703,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39739,12 +39732,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (float*) array_data(temp5);
@@ -39776,8 +39769,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39806,12 +39798,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (double*) array_data(temp5);
@@ -39843,8 +39835,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39873,12 +39864,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_CFLOAT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (npy_cfloat_wrapper*) array_data(temp5);
@@ -39910,8 +39901,7 @@
   int ecode2 = 0 ;
   PyArrayObject *array3 = NULL ;
   int is_new_object3 ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -39940,12 +39930,12 @@
     
     arg3 = (int*) array3->data;
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sort_csc_indices" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_CDOUBLE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (npy_cdouble_wrapper*) array_data(temp5);
@@ -41054,8 +41044,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41079,12 +41068,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_BYTE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (signed char*) array_data(temp5);
@@ -41109,8 +41098,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41134,12 +41122,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_UBYTE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (unsigned char*) array_data(temp5);
@@ -41164,8 +41152,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41189,12 +41176,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_SHORT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (short*) array_data(temp5);
@@ -41219,8 +41206,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41244,12 +41230,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_INT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (int*) array_data(temp5);
@@ -41274,8 +41260,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41299,12 +41284,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_LONGLONG);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (long long*) array_data(temp5);
@@ -41329,8 +41314,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41354,12 +41338,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (float*) array_data(temp5);
@@ -41384,8 +41368,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41409,12 +41392,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (double*) array_data(temp5);
@@ -41439,8 +41422,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41464,12 +41446,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_CFLOAT);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (npy_cfloat_wrapper*) array_data(temp5);
@@ -41494,8 +41476,7 @@
   int val2 ;
   int ecode2 = 0 ;
   PyArrayObject *temp3 = NULL ;
-  void *argp4 = 0 ;
-  int res4 = 0 ;
+  PyArrayObject *temp4 = NULL ;
   PyArrayObject *temp5 = NULL ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
@@ -41519,12 +41500,12 @@
     if (!temp3  || !require_contiguous(temp3) || !require_native(temp3)) SWIG_fail;
     arg3 = (int*) array_data(temp3);
   }
-  res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 |  0 );
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "sum_csc_duplicates" "', argument " "4"" of type '" "int []""'"); 
-  } 
-  arg4 = reinterpret_cast< int * >(argp4);
   {
+    temp4 = obj_to_array_no_conversion(obj3,PyArray_INT);
+    if (!temp4  || !require_contiguous(temp4) || !require_native(temp4)) SWIG_fail;
+    arg4 = (int*) array_data(temp4);
+  }
+  {
     temp5 = obj_to_array_no_conversion(obj4,PyArray_CDOUBLE);
     if (!temp5  || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail;
     arg5 = (npy_cdouble_wrapper*) array_data(temp5);
@@ -44421,7 +44402,6 @@
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
 static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_std__vectorTdouble_t = {"_p_std__vectorTdouble_t", "std::vector<double > *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_std__vectorTfloat_t = {"_p_std__vectorTfloat_t", "std::vector<float > *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_std__vectorTint_t = {"_p_std__vectorTint_t", "std::vector<int > *", 0, 0, (void*)0, 0};
@@ -44434,7 +44414,6 @@
 
 static swig_type_info *swig_type_initial[] = {
   &_swigt__p_char,
-  &_swigt__p_int,
   &_swigt__p_std__vectorTdouble_t,
   &_swigt__p_std__vectorTfloat_t,
   &_swigt__p_std__vectorTint_t,
@@ -44447,7 +44426,6 @@
 };
 
 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_std__vectorTdouble_t[] = {  {&_swigt__p_std__vectorTdouble_t, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_std__vectorTfloat_t[] = {  {&_swigt__p_std__vectorTfloat_t, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_std__vectorTint_t[] = {  {&_swigt__p_std__vectorTint_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -44460,7 +44438,6 @@
 
 static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_char,
-  _swigc__p_int,
   _swigc__p_std__vectorTdouble_t,
   _swigc__p_std__vectorTfloat_t,
   _swigc__p_std__vectorTint_t,

Modified: trunk/scipy/sparse/tests/test_sparse.py
===================================================================
--- trunk/scipy/sparse/tests/test_sparse.py	2007-12-10 22:36:31 UTC (rev 3629)
+++ trunk/scipy/sparse/tests/test_sparse.py	2007-12-10 23:25:35 UTC (rev 3630)
@@ -746,16 +746,13 @@
             assert_equal(e.dtype,mytype)
             assert_equal(e.A.dtype,mytype)
 
-    def check_ensure_sorted_indices(self):
-        #print 'sorting CSR indices'
-        data = arange( 5 )
-        col = array( [7, 2, 1, 5, 4] )
-        ptr = [0, 3, 5]
-        asp = csr_matrix( (data, col, ptr), dims = (2,10) )
+    def check_sort_indices(self):
+        data    = arange( 5 )
+        indices = array( [7, 2, 1, 5, 4] )
+        indptr  = array( [0, 3, 5] )
+        asp = csr_matrix( (data, indices, indptr), dims = (2,10) )
         bsp = asp.copy()
-        #print 'in\n', asp
-        asp.ensure_sorted_indices( inplace = True )
-        #print 'out\n', asp
+        asp.sort_indices( )
         assert_array_equal(asp.indices,[1, 2, 7, 4, 5])
         for ir in range( asp.shape[0] ):
             for ic in range( asp.shape[1] ):
@@ -839,16 +836,13 @@
             assert_equal(e.dtype, mytype)
             assert_equal(e.A.dtype, mytype)
 
-    def check_ensure_sorted_indices(self):
-        #print 'sorting CSC indices'
+    def check_sort_indices(self):
         data = arange( 5 )
         row = array( [7, 2, 1, 5, 4] )
         ptr = [0, 3, 5]
         asp = csc_matrix( (data, row, ptr), dims = (10,2) )
         bsp = asp.copy()
-        #print 'in\n', asp
-        asp.ensure_sorted_indices( inplace = True )
-        #print 'out\n', asp
+        asp.sort_indices() 
         assert_array_equal(asp.indices,[1, 2, 7, 4, 5])
         for ir in range( asp.shape[0] ):
             for ic in range( asp.shape[1] ):




More information about the Scipy-svn mailing list