mailr17851 - in /branches/frame_order_testing/extern/sobol: sobol_lib-not_tested.py sobol_lib.py sobol_test.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 16, 2012 - 11:38:
Author: bugman
Date: Tue Oct 16 11:38:17 2012
New Revision: 17851

URL: http://svn.gna.org/viewcvs/relax?rev=17851&view=rev
Log:
Python 3 update for the external Sobol library.

The command used was:
2to3 -w extern/sobol/*

The results were manually edited afterward to clean up some mess (print with 
double brackets, etc).


Modified:
    branches/frame_order_testing/extern/sobol/sobol_lib-not_tested.py
    branches/frame_order_testing/extern/sobol/sobol_lib.py
    branches/frame_order_testing/extern/sobol/sobol_test.py

Modified: branches/frame_order_testing/extern/sobol/sobol_lib-not_tested.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/extern/sobol/sobol_lib-not_tested.py?rev=17851&r1=17850&r2=17851&view=diff
==============================================================================
--- branches/frame_order_testing/extern/sobol/sobol_lib-not_tested.py 
(original)
+++ branches/frame_order_testing/extern/sobol/sobol_lib-not_tested.py Tue Oct 
16 11:38:17 2012
@@ -126,8 +126,8 @@
        try:
                output_unit = open ( output_filename, 'wt' )
        except:
-               print 'R8MAT_WRITE - Error!' 
-               print ' Could not open the output file.' 
+               print('R8MAT_WRITE - Error!') 
+               print(' Could not open the output file.') 
                return
 #
 #      Write the data.

Modified: branches/frame_order_testing/extern/sobol/sobol_lib.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/extern/sobol/sobol_lib.py?rev=17851&r1=17850&r2=17851&view=diff
==============================================================================
--- branches/frame_order_testing/extern/sobol/sobol_lib.py (original)
+++ branches/frame_order_testing/extern/sobol/sobol_lib.py Tue Oct 16 
11:38:17 2012
@@ -232,7 +232,7 @@
        global seed_save
        global v
 
-       if ( not 'initialized' in globals().keys() ):
+       if ( not 'initialized' in list(globals().keys()) ):
                initialized = 0
                dim_num_save = -1
 

Modified: branches/frame_order_testing/extern/sobol/sobol_test.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/extern/sobol/sobol_test.py?rev=17851&r1=17850&r2=17851&view=diff
==============================================================================
--- branches/frame_order_testing/extern/sobol/sobol_test.py (original)
+++ branches/frame_order_testing/extern/sobol/sobol_test.py Tue Oct 16 
11:38:17 2012
@@ -21,10 +21,10 @@
 #              Original MATLAB version by John Burkardt.
 #              PYTHON version by Corrado Chisari
 #
-       print '\nSOBOL_TEST01' 
-       print '  BITXOR is a MATLAB intrinsic function which returns' 
-       print '  the bitwise exclusive OR of two integers.' 
-       print '\n     I     J     BITXOR(I,J)\n' 
+       print('\nSOBOL_TEST01') 
+       print('  BITXOR is a MATLAB intrinsic function which returns') 
+       print('  the bitwise exclusive OR of two integers.') 
+       print('\n     I     J     BITXOR(I,J)\n') 
 
        seed = 123456789
 
@@ -34,7 +34,7 @@
                [ j, seed ] = i4_uniform ( 0, 100, seed )
                k = bitwise_xor ( i, j )
 
-               print '  %6d  %6d  %6d'%( i, j, k )
+               print('  %6d  %6d  %6d'%( i, j, k ))
 
        return
 
@@ -57,9 +57,9 @@
 #              Original MATLAB version by John Burkardt.
 #              PYTHON version by Corrado Chisari
 #
-       print '\nSOBOL_TEST02' 
-       print '  I4_BIT_HI1 returns the location of the high 1 bit.' 
-       print '\n     I     I4_BIT_HI1(I)\n'
+       print('\nSOBOL_TEST02') 
+       print('  I4_BIT_HI1 returns the location of the high 1 bit.') 
+       print('\n     I     I4_BIT_HI1(I)\n')
 
        seed = 123456789
 
@@ -69,7 +69,7 @@
 
                j = i4_bit_hi1 ( i )
 
-               print '%6d %6d'%( i, j )
+               print('%6d %6d'%( i, j ))
        return
        
 
@@ -91,9 +91,9 @@
 #              Original MATLAB version by John Burkardt.
 #              PYTHON version by Corrado Chisari
 #
-       print '\nSOBOL_TEST03'
-       print '  I4_BIT_LO0 returns the location of the low 0 bit.'
-       print '\n     I     I4_BIT_LO0(I)'
+       print('\nSOBOL_TEST03')
+       print('  I4_BIT_LO0 returns the location of the low 0 bit.')
+       print('\n     I     I4_BIT_LO0(I)')
 
        seed = 123456789
 
@@ -103,7 +103,7 @@
 
                j = i4_bit_lo0 ( i )
 
-               print '%6d %6d'%( i, j )
+               print('%6d %6d'%( i, j ))
        return
 
 
@@ -126,10 +126,10 @@
 #              Original MATLAB version by John Burkardt.
 #              PYTHON version by Corrado Chisari
 #
-       print '\nSOBOL_TEST04'
-       print '  I4_SOBOL returns the next element'
-       print '  of a Sobol sequence.'
-       print '\n  In this test, we call I4_SOBOL repeatedly.\n'
+       print('\nSOBOL_TEST04')
+       print('  I4_SOBOL returns the next element')
+       print('  of a Sobol sequence.')
+       print('\n  In this test, we call I4_SOBOL repeatedly.\n')
 
        dim_max = 4
 
@@ -138,18 +138,18 @@
                seed = 0
                qs = prime_ge ( dim_num )
 
-               print '\n  Using dimension DIM_NUM =   %d'%dim_num
-               print '\n  Seed  Seed   I4_SOBOL'
-               print '  In    Out\n'
+               print('\n  Using dimension DIM_NUM =   %d'%dim_num)
+               print('\n  Seed  Seed   I4_SOBOL')
+               print('  In    Out\n')
                for i in range( 0, 111):
                        [ r, seed_out ] = i4_sobol ( dim_num, seed )
                        if ( i <= 11 or 95 <= i ):
                                out='%6d %6d  '%(seed, seed_out )
                                for j in range (0, dim_num):
                                        out+='%10f  '%r[j]
-                               print out
+                               print(out)
                        elif ( i == 12 ):
-                               print '......................'
+                               print('......................')
                        seed = seed_out
        return
 
@@ -173,89 +173,89 @@
 #              Original MATLAB version by John Burkardt.
 #              PYTHON version by Corrado Chisari
 #
-  print ''
-  print 'SOBOL_TEST05'
-  print '  I4_SOBOL computes the next element of a Sobol sequence.'
-  print ''
-  print '  In this test, we demonstrate how the SEED can be'
-  print '  manipulated to skip ahead in the sequence, or'
-  print '  to come back to any part of the sequence.'
-  print ''
+  print('')
+  print('SOBOL_TEST05')
+  print('  I4_SOBOL computes the next element of a Sobol sequence.')
+  print('')
+  print('  In this test, we demonstrate how the SEED can be')
+  print('  manipulated to skip ahead in the sequence, or')
+  print('  to come back to any part of the sequence.')
+  print('')
 
   dim_num = 3
 
-  print ''
-  print '  Using dimension DIM_NUM =   %d\n'%dim_num 
+  print('')
+  print('  Using dimension DIM_NUM =   %d\n'%dim_num) 
 
   seed = 0
 
-  print ''
-  print '  Seed  Seed   I4_SOBOL'
-  print '  In    Out'
-  print ''
+  print('')
+  print('  Seed  Seed   I4_SOBOL')
+  print('  In    Out')
+  print('')
 
   for i in range( 0 , 10+1):
     [ r, seed_out ] = i4_sobol ( dim_num, seed )
     out= '%6d %6d  '%( seed, seed_out )
     for j in range( 1 , dim_num+1):
       out+= '%10f  '% r[j-1] 
-    print out
-    seed = seed_out
-
-  print ''
-  print '  Jump ahead by increasing SEED:'
-  print ''
+    print(out)
+    seed = seed_out
+
+  print('')
+  print('  Jump ahead by increasing SEED:')
+  print('')
 
   seed = 100
 
-  print ''
-  print '  Seed  Seed   I4_SOBOL'
-  print '  In    Out'
-  print ''
+  print('')
+  print('  Seed  Seed   I4_SOBOL')
+  print('  In    Out')
+  print('')
 
   for i in range( 1 , 6):
     [ r, seed_out ] = i4_sobol ( dim_num, seed )
     out='%6d %6d  '%( seed, seed_out)
     for j in range( 1 , dim_num+1):
       out+= '%10f  '% r[j-1] 
-    print out
-    seed = seed_out
-  print ''
-  print '  Jump back by decreasing SEED:'
-  print ''
+    print(out)
+    seed = seed_out
+  print('')
+  print('  Jump back by decreasing SEED:')
+  print('')
 
   seed = 3
 
-  print ''
-  print '  Seed  Seed   I4_SOBOL'
-  print '  In    Out'
-  print ''
+  print('')
+  print('  Seed  Seed   I4_SOBOL')
+  print('  In    Out')
+  print('')
 
   for i in range( 0 , 11):
     [ r, seed_out ] = i4_sobol ( dim_num, seed )
     out='%6d %6d  '%( seed, seed_out)
     for j in range( 1 , dim_num+1):
       out+= '%10f  '% r[j-1] 
-    print out
-    seed = seed_out
-
-  print ''
-  print '  Jump back by decreasing SEED:'
-  print ''
+    print(out)
+    seed = seed_out
+
+  print('')
+  print('  Jump back by decreasing SEED:')
+  print('')
 
   seed = 98
 
-  print ''
-  print '  Seed  Seed   I4_SOBOL'
-  print '  In    Out'
-  print ''
+  print('')
+  print('  Seed  Seed   I4_SOBOL')
+  print('  In    Out')
+  print('')
 
   for i in range( 1 , 6):
     [ r, seed_out ] = i4_sobol ( dim_num, seed )
     out= '%6d %6d  '%( seed, seed_out )
     for j in range( 1 , dim_num+1):
       out+= '%10f  '%r[j-1] 
-    print out
+    print(out)
     seed = seed_out
 
   return
@@ -266,9 +266,9 @@
 ##############MAIN#############
 def main(argv=None):
        d=datetime.datetime.today()
-       print d.strftime("%d-%b-%Y %H:%M:%S")
-       print '\nSOBOL_TEST'
-       print '  Test the MATLAB SOBOL routines.'
+       print(d.strftime("%d-%b-%Y %H:%M:%S"))
+       print('\nSOBOL_TEST')
+       print('  Test the MATLAB SOBOL routines.')
 
        sobol_test01()
        sobol_test02()
@@ -276,11 +276,11 @@
        sobol_test04()
        sobol_test05()
        
-       print 'SOBOL_TEST'
-       print '  Normal end of execution.'
+       print('SOBOL_TEST')
+       print('  Normal end of execution.')
 
        d=datetime.datetime.today()
-       print d.strftime("%d-%b-%Y %H:%M:%S")
+       print(d.strftime("%d-%b-%Y %H:%M:%S"))
 
 if __name__ == "__main__":
        main()




Related Messages


Powered by MHonArc, Updated Tue Oct 16 12:00:02 2012