[Scipy-svn] r3488 - trunk/scipy/sparse

scipy-svn@scip... scipy-svn@scip...
Fri Nov 2 01:39:34 CDT 2007


Author: wnbell
Date: 2007-11-02 01:39:32 -0500 (Fri, 02 Nov 2007)
New Revision: 3488

Modified:
   trunk/scipy/sparse/sparse.py
Log:
small edit


Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py	2007-11-02 06:09:29 UTC (rev 3487)
+++ trunk/scipy/sparse/sparse.py	2007-11-02 06:39:32 UTC (rev 3488)
@@ -959,10 +959,10 @@
                 # It's a tuple of matrix dimensions (M, N)
                 self.shape = arg1   #spmatrix checks for errors here
                 M, N = self.shape
-                self.dtype = getdtype(dtype, default=float)
-                self.data = zeros((nzmax,), self.dtype)
+                self.dtype   = getdtype(dtype, default=float)
+                self.data    = zeros((nzmax,), self.dtype)
                 self.indices = zeros((nzmax,), intc)
-                self.indptr = zeros((N+1,), intc)
+                self.indptr  = zeros((N+1,), intc)
             else:
                 try:
                     # Try interpreting it as (data, ij)
@@ -977,14 +977,10 @@
                         raise ValueError, "unrecognized form for csc_matrix constructor"
                     else:
                         self.dtype = getdtype(dtype, data)
-                        if copy:
-                            self.data    = array(data)
-                            self.indices = array(indices)
-                            self.indptr  = array(indptr)
-                        else:
-                            self.data    = asarray(data)
-                            self.indices = asarray(indices)
-                            self.indptr  = asarray(indptr)
+                        self.dtype   = getdtype(dtype, data)
+                        self.data    = array(data, copy=copy, dtype=self.dtype)
+                        self.indices = array(indices, copy=copy)
+                        self.indptr  = array(indptr, copy=copy)
                 else:
                     # (data, ij) format
                     other = coo_matrix((data, ij), dims=dims )
@@ -1248,10 +1244,10 @@
                 # It's a tuple of matrix dimensions (M, N)
                 self.shape = arg1   #spmatrix checks for errors here
                 M, N = self.shape
-                self.dtype = getdtype(dtype, default=float)
-                self.data = zeros((nzmax,), self.dtype)
+                self.dtype   = getdtype(dtype, default=float)
+                self.data    = zeros((nzmax,), self.dtype)
                 self.indices = zeros((nzmax,), intc)
-                self.indptr = zeros((M+1,), intc)
+                self.indptr  = zeros((M+1,), intc)
             else:
                 try:
                     # Try interpreting it as (data, ij)
@@ -1265,15 +1261,10 @@
                     except:
                         raise ValueError, "unrecognized form for csr_matrix constructor"
                     else:
-                        self.dtype = getdtype(dtype, data)
-                        if copy:
-                            self.data    = array(data, dtype=self.dtype)
-                            self.indices = array(indices)
-                            self.indptr  = array(indptr)
-                        else:
-                            self.data    = asarray(data, dtype=self.dtype)
-                            self.indices = asarray(indices)
-                            self.indptr  = asarray(indptr)
+                        self.dtype   = getdtype(dtype, data)
+                        self.data    = array(data, copy=copy, dtype=self.dtype)
+                        self.indices = array(indices, copy=copy)
+                        self.indptr  = array(indptr, copy=copy)
                 else:
                     # (data, ij) format
                     other = coo_matrix((data, ij), dims=dims )



More information about the Scipy-svn mailing list