[Scipy-svn] r3628 - trunk/scipy/sparse
scipy-svn@scip...
scipy-svn@scip...
Mon Dec 10 15:34:54 CST 2007
Author: wnbell
Date: 2007-12-10 15:34:27 -0600 (Mon, 10 Dec 2007)
New Revision: 3628
Modified:
trunk/scipy/sparse/sparse.py
Log:
made coo_matrix.dtype a property
Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py 2007-12-10 20:46:04 UTC (rev 3627)
+++ trunk/scipy/sparse/sparse.py 2007-12-10 21:34:27 UTC (rev 3628)
@@ -2057,7 +2057,6 @@
self.row = asarray(ij[0])
self.col = asarray(ij[1])
self.data = asarray(obj)
- self.dtype = self.data.dtype
if dims is None:
if len(self.row) == 0 or len(self.col) == 0:
@@ -2076,8 +2075,7 @@
if not isinstance(dims, tuple) or not isintlike(dims[0]):
raise TypeError, "dimensions not understood"
self.shape = dims
- self.dtype = getdtype(dtype, default=float)
- self.data = array([])
+ self.data = array([],getdtype(dtype, default=float))
self.row = array([],dtype=intc)
self.col = array([],dtype=intc)
else:
@@ -2090,12 +2088,16 @@
if len(M.shape) != 2:
raise TypeError, "expected rank 2 array or matrix"
self.shape = M.shape
- self.dtype = M.dtype
self.row,self.col = (M != 0).nonzero()
self.data = M[self.row,self.col]
self._check()
+ def _get_dtype(self):
+ return self.data.dtype
+ def _set_dtype(self,newtype):
+ self.data.dtype = newtype
+ dtype = property(fget=_get_dtype,fset=_set_dtype)
def _check(self):
""" Checks for consistency and stores the number of non-zeros as
@@ -2154,7 +2156,6 @@
return csc_matrix((data, indices, indptr), self.shape)
-
def tocsr(self):
if self.nnz == 0:
return csr_matrix(self.shape, dtype=self.dtype)
More information about the Scipy-svn
mailing list