[Scipy-svn] r3468 - trunk/scipy/sparse
scipy-svn at scipy.org
scipy-svn at scipy.org
Sat Oct 27 14:25:14 EDT 2007
Author: wnbell
Date: 2007-10-27 13:25:05 -0500 (Sat, 27 Oct 2007)
New Revision: 3468
Modified:
trunk/scipy/sparse/sparse.py
Log:
for non-integer dtypes, replace exception with warning and cast
Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py 2007-10-27 17:09:07 UTC (rev 3467)
+++ trunk/scipy/sparse/sparse.py 2007-10-27 18:25:05 UTC (rev 3468)
@@ -514,10 +514,14 @@
class _cs_matrix(spmatrix):
def _check(self):
- if self.indptr.dtype > numpy.dtype('int64'):
- raise TypeError,'indptr array has invalid dtype'
- if self.indices.dtype > numpy.dtype('int64'):
- raise TypeError,'indices array has invalid dtype'
+ if self.indptr.dtype.kind != 'i':
+ warnings.warn("indptr array has non-integer dtype. " \
+ "Casting from %s to int" % self.indptr.dtype.name )
+ self.indptr = self.indptr.astype('i')
+ if self.indices.dtype.kind != 'i':
+ warnings.warn("indices array has non-integer dtype. " \
+ "Casting from %s to int" % self.indices.dtype.name )
+ self.indices = self.indices.astype('i')
#TODO handle non-native byteorder better
self.indptr = to_native(self.indptr)
More information about the Scipy-svn
mailing list