[Scipy-svn] r5313 - in trunk/scipy: io io/matlab sparse/linalg/dsolve/umfpack/tests

scipy-svn@scip... scipy-svn@scip...
Wed Dec 31 16:22:46 CST 2008


Author: jarrod.millman
Date: 2008-12-31 16:22:45 -0600 (Wed, 31 Dec 2008)
New Revision: 5313

Modified:
   trunk/scipy/io/matlab/mio.py
   trunk/scipy/io/mmio.py
   trunk/scipy/sparse/linalg/dsolve/umfpack/tests/try_umfpack.py
Log:
use string method over slicing


Modified: trunk/scipy/io/matlab/mio.py
===================================================================
--- trunk/scipy/io/matlab/mio.py	2008-12-31 22:16:36 UTC (rev 5312)
+++ trunk/scipy/io/matlab/mio.py	2008-12-31 22:22:45 UTC (rev 5313)
@@ -25,7 +25,7 @@
     warnings.warn('Searching for mat files on python system path will be ' +
                   'removed in future versions of scipy',
                    FutureWarning, stacklevel=2)
-    if appendmat and file_name[-4:] == ".mat":
+    if appendmat and file_name.endswith(".mat"):
         file_name = file_name[:-4]
     if os.sep in file_name:
         full_name = file_name

Modified: trunk/scipy/io/mmio.py
===================================================================
--- trunk/scipy/io/mmio.py	2008-12-31 22:16:36 UTC (rev 5312)
+++ trunk/scipy/io/mmio.py	2008-12-31 22:22:45 UTC (rev 5313)
@@ -208,10 +208,10 @@
                     elif os.path.isfile(filespec+'.mtx.bz2'):
                         filespec = filespec + '.mtx.bz2'
                 # open filename
-                if filespec[-3:] == '.gz':
+                if filespec.endswith('.gz'):
                     import gzip
                     stream = gzip.open(filespec, mode)
-                elif filespec[-4:] == '.bz2':
+                elif filespec.endswith('.bz2'):
                     import bz2
                     stream = bz2.BZ2File(filespec, 'r')
                 else:

Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/tests/try_umfpack.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/umfpack/tests/try_umfpack.py	2008-12-31 22:16:36 UTC (rev 5312)
+++ trunk/scipy/sparse/linalg/dsolve/umfpack/tests/try_umfpack.py	2008-12-31 22:22:45 UTC (rev 5313)
@@ -88,7 +88,7 @@
     print 'format:', options.format
 
     print 'reading...'
-    if fileName[-3:] == '.gz':
+    if fileName.endswith('.gz'):
         fd = gzip.open( fileName )
     else:
         fd = open( fileName )



More information about the Scipy-svn mailing list