[Scipy-svn] r3526 - in trunk/scipy: interpolate linalg signal special special/amos weave weave/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Nov 13 01:51:08 EST 2007


Author: jarrod.millman
Date: 2007-11-13 00:51:00 -0600 (Tue, 13 Nov 2007)
New Revision: 3526

Modified:
   trunk/scipy/interpolate/fitpack.py
   trunk/scipy/linalg/interface_gen.py
   trunk/scipy/signal/filter_design.py
   trunk/scipy/special/amos/setup.py
   trunk/scipy/special/gendoc.py
   trunk/scipy/weave/catalog.py
   trunk/scipy/weave/ext_tools.py
   trunk/scipy/weave/tests/test_c_spec.py
   trunk/scipy/weave/tests/test_catalog.py
   trunk/scipy/weave/tests/test_slice_handler.py
   trunk/scipy/weave/tests/test_standard_array_spec.py
   trunk/scipy/weave/tests/weave_test_utils.py
Log:
remove use of deprecated string module


Modified: trunk/scipy/interpolate/fitpack.py
===================================================================
--- trunk/scipy/interpolate/fitpack.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/interpolate/fitpack.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -823,10 +823,10 @@
         return (tt, cc, k)
 
 if __name__ == "__main__":
-    import sys,string
+    import sys
     runtest=range(10)
     if len(sys.argv[1:])>0:
-        runtest=map(string.atoi,sys.argv[1:])
+        runtest=map(int,sys.argv[1:])
     put=sys.stdout.write
     def norm2(x):
         return dot(transpose(x),x)

Modified: trunk/scipy/linalg/interface_gen.py
===================================================================
--- trunk/scipy/linalg/interface_gen.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/linalg/interface_gen.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -2,7 +2,9 @@
 
 #!/usr/bin/env python
 
-import string,os,sys
+import os
+import sys
+
 if sys.version[:3]>='2.3':
     import re
 else:
@@ -19,7 +21,7 @@
     subroutine_list = subroutine_exp.findall(interface)
     function_list = function_exp.findall(interface)
     subroutine_list = subroutine_list + function_list
-    subroutine_list = map(lambda x: string.strip(x),subroutine_list)
+    subroutine_list = map(lambda x: x.strip(),subroutine_list)
     return subroutine_list
 
 def real_convert(val_string):
@@ -35,7 +37,7 @@
         sub = regexp.search(interface)
         if sub is None: break
         converted = converter(sub.group(1))
-        interface = string.replace(interface,sub.group(),converted)
+        interface = interface.replace(sub.group(),converted)
     return interface
 
 def generic_expand(generic_interface,skip_names=[]):
@@ -80,33 +82,30 @@
             continue
         type_chars = m.group(1)
         # get rid of spaces
-        type_chars = string.replace(type_chars,' ','')
+        type_chars = type_chars.replace(' ','')
         # get a list of the characters (or character pairs)
-        type_chars = string.split(type_chars,',')
+        type_chars = type_chars.split(',')
         # Now get rid of the special tag that contained the types
         sub = re.sub(type_exp,'<tchar>',sub)
         m = TYPE_EXP.search(sub)
         if m is not None:
             sub = re.sub(TYPE_EXP,'<TCHAR>',sub)
-        sub_generic = string.strip(sub)
+        sub_generic = sub.strip()
         for char in type_chars:
             type_in,type_out,converter, rtype_in = generic_types[char]
             sub = convert_types(sub_generic,converter)
-            function_def = string.replace(sub,'<tchar>',char)
-            function_def = string.replace(function_def,'<TCHAR>',string.upper(char))
-
-            function_def = string.replace(function_def,'<type_in>',type_in)
-            function_def = string.replace(function_def,'<type_in_c>',
+            function_def = sub.replace('<tchar>',char)
+            function_def = function_def.replace('<TCHAR>',char.upper())
+            function_def = function_def.replace('<type_in>',type_in)
+            function_def = function_def.replace('<type_in_c>',
                                           generic_c_types[type_in])
-            function_def = string.replace(function_def,'<type_in_cc>',
+            function_def = function_def.replace('<type_in_cc>',
                                           generic_cc_types[type_in])
-
-            function_def = string.replace(function_def,'<rtype_in>',rtype_in)
-            function_def = string.replace(function_def,'<rtype_in_c>',
+            function_def = function_def.replace('<rtype_in>',rtype_in)
+            function_def = function_def.replace('<rtype_in_c>',
                                           generic_c_types[rtype_in])
-
-            function_def = string.replace(function_def,'<type_out>',type_out)
-            function_def = string.replace(function_def,'<type_out_c>',
+            function_def = function_def.replace('<type_out>',type_out)
+            function_def = function_def.replace('<type_out_c>',
                                           generic_c_types[type_out])
             m = routine_name.match(function_def)
             if m:
@@ -136,8 +135,7 @@
     include_files = include_exp.findall(interface_in)
     for filename in include_files:
         f = open(os.path.join(sdir,filename))
-        interface_in = string.replace(interface_in,
-                                      '<include_file=%s>'%filename,
+        interface_in = interface_in.replace('<include_file=%s>'%filename,
                                       f.read())
         f.close()
     return interface_in

Modified: trunk/scipy/signal/filter_design.py
===================================================================
--- trunk/scipy/signal/filter_design.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/signal/filter_design.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,6 +1,8 @@
 """Filter design.
 """
 
+import types
+
 import numpy
 from numpy import atleast_1d, poly, polyval, roots, real, asarray, allclose, \
     resize, pi, absolute, logspace, r_, sqrt, tan, log10, arctan, arcsinh, \
@@ -8,7 +10,6 @@
 from numpy import mintypecode
 from scipy import special, optimize
 from scipy.misc import comb
-import string, types
 
 
 abs = absolute
@@ -400,7 +401,7 @@
     SEE ALSO butterord, cheb1ord, cheb2ord, ellipord
     """
 
-    ftype, btype, output = [string.lower(x) for x in (ftype, btype, output)]
+    ftype, btype, output = [x.lower() for x in (ftype, btype, output)]
     Wn = asarray(Wn)
     try:
         btype = band_dict[btype]

Modified: trunk/scipy/special/amos/setup.py
===================================================================
--- trunk/scipy/special/amos/setup.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/special/amos/setup.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,7 +1,7 @@
 import distutils
 from distutils.core import setup, Extension
 import distutils.dep_util
-import os,string
+import os
 
 def fortran_extension(module_name, c_files, fortran_files, library_dirs,
                       libraries):
@@ -18,15 +18,14 @@
     def __init__(self):
         self.compiler_name = 'g77'
     def to_object(self,dirty_files):
-        files = string.join(dirty_files)
+        files = dirty_files.join()
         cmd = self.compiler_name + ' -c ' + files
         print cmd
         failure = os.system(cmd)
         if failure:
             raise ValueError, 'failure during compile'
     def object_to_library(self,library_name,object_files):
-        import string
-        objects = string.join(object_files)
+        objects = object_files.join()
         cmd = 'ar -cr lib%s.a %s' % (library_name,objects)
         print cmd
         os.system(cmd)

Modified: trunk/scipy/special/gendoc.py
===================================================================
--- trunk/scipy/special/gendoc.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/special/gendoc.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -2,7 +2,6 @@
 
 """generate cephes_doc.h from included_functions.html"""
 
-import string
 
 def parse(infile):
     d={}
@@ -10,19 +9,19 @@
     val=''
     prev_line = ''
     for line in infile.readlines():
-        if not string.strip(line):
+        if not line.strip():
             continue
         if line[0]=='<':
             if key and val:
-                d[key]=string.strip(val)
+                d[key]=val.strip()
                 key,val=None,None
             if line[:4]=='<DT>':
-                tok=string.split(line)
-                tok=string.split(tok[-1],'(')
+                tok=line.split()
+                tok=tok[-1].split('(')
                 key=tok[0]
             elif line[:4]=='<DD>' and key:
                 prev_line = prev_line[4:]
-                tok = string.split(prev_line,' = ')
+                tok = prev_line.split(' = ')
                 val=tok[0]+'='+line[4:]
         else:
             if val:

Modified: trunk/scipy/weave/catalog.py
===================================================================
--- trunk/scipy/weave/catalog.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/catalog.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -31,7 +31,8 @@
     persistent catalog for future use by python sessions.
 """
 
-import os,sys,string
+import os
+import sys
 import pickle
 import socket
 import tempfile
@@ -71,7 +72,7 @@
                     # if a non-builtin also has it.  Otherwise quit and
                     # consider the module found. (ain't perfect, but will
                     # have to do for now).
-                    if string.find('(built-in)',str(mod)) is -1:
+                    if str(mod) not in '(built-in)':
                         break
 
             except (TypeError, KeyError, ImportError):

Modified: trunk/scipy/weave/ext_tools.py
===================================================================
--- trunk/scipy/weave/ext_tools.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/ext_tools.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,5 +1,6 @@
-import os, sys
-import string, re
+import os
+import sys
+import re
 
 import catalog
 import build_tools
@@ -39,20 +40,19 @@
 
             This code got a lot uglier when I added local_dict...
         """
-        join = string.join
 
         declare_return = 'py::object return_val;\n' \
                          'int exception_occured = 0;\n' \
                          'PyObject *py_local_dict = NULL;\n'
         arg_string_list = self.arg_specs.variable_as_strings() + ['"local_dict"']
-        arg_strings = join(arg_string_list,',')
+        arg_strings = arg_string_list.join(',')
         if arg_strings: arg_strings += ','
         declare_kwlist = 'static char *kwlist[] = {%s NULL};\n' % arg_strings
 
-        py_objects = join(self.arg_specs.py_pointers(),', ')
-        init_flags = join(self.arg_specs.init_flags(),', ')
-        init_flags_init = join(self.arg_specs.init_flags(),'= ')
-        py_vars = join(self.arg_specs.py_variables(),' = ')
+        py_objects = self.arg_specs.py_pointers().join(', ')
+        init_flags = self.arg_specs.init_flags().join(', ')
+        init_flags_init = self.arg_specs.init_flags().join('= ')
+        py_vars = self.arg_specs.py_variables().join(' = ')
         if py_objects:
             declare_py_objects  = 'PyObject ' + py_objects +';\n'
             declare_py_objects += 'int '+ init_flags + ';\n'
@@ -66,7 +66,7 @@
         #cnt = len(arg_list)
         #declare_cleanup = "blitz::TinyVector<PyObject*,%d> clean_up(0);\n" % cnt
 
-        ref_string = join(self.arg_specs.py_references(),', ')
+        ref_string = self.arg_specs.py_references().join(', ')
         if ref_string:
             ref_string += ', &py_local_dict'
         else:
@@ -85,7 +85,7 @@
         for arg in self.arg_specs:
             arg_strings.append(arg.declaration_code())
             arg_strings.append(arg.init_flag() +" = 1;\n")
-        code = string.join(arg_strings,"")
+        code = (arg_strings.join("")
         return code
 
     def arg_cleanup_code(self):
@@ -97,14 +97,14 @@
             code +=     indent(arg.cleanup_code(),4)
             code += "}\n"
             arg_strings.append(code)
-        code = string.join(arg_strings,"")
+        code = arg_strings.join("")
         return code
 
     def arg_local_dict_code(self):
         arg_strings = []
         for arg in self.arg_specs:
             arg_strings.append(arg.local_dict_code())
-        code = string.join(arg_strings,"")
+        code = arg_strings.join("")
         return code
 
     def function_code(self):
@@ -454,7 +454,7 @@
 
 def indent(st,spaces):
     indention = ' '*spaces
-    indented = indention + string.replace(st,'\n','\n'+indention)
+    indented = indention + st.replace('\n','\n'+indention)
     # trim off any trailing spaces
     indented = re.sub(r' +$',r'',indented)
     return indented

Modified: trunk/scipy/weave/tests/test_c_spec.py
===================================================================
--- trunk/scipy/weave/tests/test_c_spec.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/tests/test_c_spec.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,5 +1,6 @@
 import time
-import os,sys
+import os
+import sys
 
 # Note: test_dir is global to this file.
 #       It is made by setup_test_location()
@@ -22,10 +23,9 @@
     return m
 
 def remove_whitespace(in_str):
-    import string
-    out = string.replace(in_str," ","")
-    out = string.replace(out,"\t","")
-    out = string.replace(out,"\n","")
+    out = in_str.replace(" ","")
+    out = out.replace("\t","")
+    out = out.replace("\n","")
     return out
 
 def print_assert_equal(test_string,actual,desired):

Modified: trunk/scipy/weave/tests/test_catalog.py
===================================================================
--- trunk/scipy/weave/tests/test_catalog.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/tests/test_catalog.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,4 +1,5 @@
-import sys, os
+import sys
+import os
 
 
 from numpy.testing import *

Modified: trunk/scipy/weave/tests/test_slice_handler.py
===================================================================
--- trunk/scipy/weave/tests/test_slice_handler.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/tests/test_slice_handler.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -129,10 +129,9 @@
         self.generic_test(test,desired)
 
 def replace_whitespace(in_str):
-    import string
-    out = string.replace(in_str," ","")
-    out = string.replace(out,"\t","")
-    out = string.replace(out,"\n","")
+    out = in_str.replace(" ","")
+    out = out.replace("\t","")
+    out = out.replace("\n","")
     return out
 
 class TestTransformSlices(NumpyTestCase):
@@ -143,7 +142,6 @@
         actual = ast_to_string(ast_list)
         # Remove white space from expressions so that equivelant
         # but differently formatted string will compare equally
-        import string
         actual = replace_whitespace(actual)
         desired = replace_whitespace(desired)
         print_assert_equal(suite_string,actual,desired)

Modified: trunk/scipy/weave/tests/test_standard_array_spec.py
===================================================================
--- trunk/scipy/weave/tests/test_standard_array_spec.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/tests/test_standard_array_spec.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -6,10 +6,9 @@
 restore_path()
 
 def remove_whitespace(in_str):
-    import string
-    out = string.replace(in_str," ","")
-    out = string.replace(out,"\t","")
-    out = string.replace(out,"\n","")
+    out = in_str.replace(" ","")
+    out = out.replace("\t","")
+    out = out.replace("\n","")
     return out
 
 def print_assert_equal(test_string,actual,desired):

Modified: trunk/scipy/weave/tests/weave_test_utils.py
===================================================================
--- trunk/scipy/weave/tests/weave_test_utils.py	2007-11-13 06:10:03 UTC (rev 3525)
+++ trunk/scipy/weave/tests/weave_test_utils.py	2007-11-13 06:51:00 UTC (rev 3526)
@@ -1,11 +1,12 @@
-import os,sys,string
+import os
+import sys
+import string
 import pprint
 
 def remove_whitespace(in_str):
-    import string
-    out = string.replace(in_str," ","")
-    out = string.replace(out,"\t","")
-    out = string.replace(out,"\n","")
+    out = in_str.replace(" ","")
+    out = out.replace("\t","")
+    out = out.replace("\n","")
     return out
 
 def print_assert_equal(test_string,actual,desired):




More information about the Scipy-svn mailing list