mailr9452 - in /branches/multi_processor_merge: multi/ specific_fns/model_free/


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

Header


Content

Posted by edward on September 03, 2009 - 15:14:
Author: bugman
Date: Thu Sep  3 15:13:50 2009
New Revision: 9452

URL: http://svn.gna.org/viewcvs/relax?rev=9452&view=rev
Log:
Updates for Python3k.

The command used was:
2to3 -w \
-x except \
-x import \
-x imports \
-x long \
-x numliterals \
-x xrange \
relax .

This is from the docs/2to3_checklist document.  Two print statements changed 
in multi/processor.py
had to be manually fixed afterwards, as the end and file args to the print 
statement do not exist in
all python 2.x versions.


Modified:
    branches/multi_processor_merge/multi/commands.py
    branches/multi_processor_merge/multi/mpi4py_processor.py
    branches/multi_processor_merge/multi/multi_processor_base.py
    branches/multi_processor_merge/multi/processor.py
    branches/multi_processor_merge/multi/uni_processor.py
    branches/multi_processor_merge/specific_fns/model_free/mf_minimise.py
    
branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py

Modified: branches/multi_processor_merge/multi/commands.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/commands.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/commands.py (original)
+++ branches/multi_processor_merge/multi/commands.py Thu Sep  3 15:13:50 2009
@@ -59,7 +59,7 @@
 
 
     def run(self, processor, completed):
-        for property, value in self.property_map.items():
+        for property, value in list(self.property_map.items()):
             try:
                 setattr(processor, property, value)
                 processor.return_object(processor.NULL_RESULT)

Modified: branches/multi_processor_merge/multi/mpi4py_processor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/mpi4py_processor.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/mpi4py_processor.py (original)
+++ branches/multi_processor_merge/multi/mpi4py_processor.py Thu Sep  3 
15:13:50 2009
@@ -116,7 +116,7 @@
 
         msg = 'warning: mpi4py_processor is using 1 masters and %d slave 
processors you requested %d slaves\n'
         if processor_size != (mpi_processor_size):
-            print msg % (mpi_processor_size, processor_size)
+            print(msg % (mpi_processor_size, processor_size))
 
         super(Mpi4py_processor, 
self).__init__(processor_size=mpi_processor_size, callback=callback)
 

Modified: branches/multi_processor_merge/multi/multi_processor_base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/multi_processor_base.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/multi_processor_base.py (original)
+++ branches/multi_processor_merge/multi/multi_processor_base.py Thu Sep  3 
15:13:50 2009
@@ -53,7 +53,7 @@
     def run(self, processor, batched_memo):
         processor.assert_on_master()
         if batched_memo != None:
-            msg = "batched result commands shouldn't have memo values, memo: 
" + `batched_memo`
+            msg = "batched result commands shouldn't have memo values, memo: 
" + repr(batched_memo)
             raise ValueError(msg)
 
         for result_command in self.result_commands:
@@ -311,8 +311,8 @@
 
                     if result.completed:
                         idle_set.add(result.rank)
-                        print 'idle set', `idle_set`
-                        print 'running_set', `running_set`
+                        print('idle set', repr(idle_set))
+                        print('running_set', repr(running_set))
                         running_set.remove(result.rank)
 
                     result_queue.put(result)

Modified: branches/multi_processor_merge/multi/processor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/processor.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/processor.py (original)
+++ branches/multi_processor_merge/multi/processor.py Thu Sep  3 15:13:50 2009
@@ -131,7 +131,7 @@
     #try:
     module = __import__(module_path, globals(), locals(), [])
     if verbose:
-        print 'loaded module %s' % module_path
+        print('loaded module %s' % module_path)
     #except Exception, e:
     #    if verbose:
     #        print 'failed to load module_path %s' % module_path
@@ -170,7 +170,7 @@
 
     # Check that the processor type is supported.
     if processor_name not in ['uni', 'mpi4py']:
-        raise RelaxError, "The processor type '%s' is not supported." % 
processor_name
+        raise RelaxError("The processor type '%s' is not supported." % 
processor_name)
 
     # The Processor details.
     processor_name = processor_name + '_processor'
@@ -203,21 +203,21 @@
 # FIXME useful debugging code but where to put it
 def print_file_lineno(range=xrange(1, 2)):
     for level in range:
-        print '<< ', level,
+        print('<< ', level)
         try:
             file_name = sys._getframe(level).f_code.co_filename
             function_name = sys._getframe(level).f_code.co_name
             line_number = sys._getframe(level).f_lineno
             msg = ': %s - %s - %d>>' % (file_name, function_name, 
line_number)
-            print msg
+            print(msg)
         except Exception, e:
-            print e
+            print(e)
             break
 
 
 #FIXME: useful for debugging but where to put it
 def print_message(processor, message):
-    f = open('error' + `processor.rank()` + '.txt', 'a')
+    f = open('error' + repr(processor.rank()) + '.txt', 'a')
     f.write(message + '\n')
     f.flush()
     f.close()
@@ -666,7 +666,7 @@
         if self.rank() == 0:
             end_time = time.time()
             time_delta_str = self.get_time_delta(self.start_time, end_time)
-            print '\nOverall runtime: ' + time_delta_str + '\n'
+            print('\nOverall runtime: ' + time_delta_str + '\n')
 
 
     def pre_run(self):

Modified: branches/multi_processor_merge/multi/uni_processor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/uni_processor.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/uni_processor.py (original)
+++ branches/multi_processor_merge/multi/uni_processor.py Thu Sep  3 15:13:50 
2009
@@ -46,8 +46,8 @@
         super(Uni_processor, self).__init__(processor_size=1, 
callback=callback)
 
         if processor_size > 1:
-            print 'warning: uniprocessor can only support 1 processor you 
requested %d' % processor_size
-            print 'continuing...\n'
+            print('warning: uniprocessor can only support 1 processor you 
requested %d' % processor_size)
+            print('continuing...\n')
 
         self.command_queue = []
         self.memo_map = {}

Modified: 
branches/multi_processor_merge/specific_fns/model_free/mf_minimise.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/specific_fns/model_free/mf_minimise.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- branches/multi_processor_merge/specific_fns/model_free/mf_minimise.py 
(original)
+++ branches/multi_processor_merge/specific_fns/model_free/mf_minimise.py Thu 
Sep  3 15:13:50 2009
@@ -483,11 +483,11 @@
 
         # Catch infinite chi-squared values.
         if isInf(func):
-            raise RelaxInfError, 'chi-squared'
+            raise RelaxInfError('chi-squared')
 
         # Catch chi-squared values of NaN.
         if isNaN(func):
-            raise RelaxNaNError, 'chi-squared'
+            raise RelaxNaNError('chi-squared')
 
         # Scaling.
         if scaling:

Modified: 
branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py?rev=9452&r1=9451&r2=9452&view=diff
==============================================================================
--- 
branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py
 (original)
+++ 
branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py
 Thu Sep  3 15:13:50 2009
@@ -92,21 +92,21 @@
         grid_size = sgm.grid_size
 
         if sgm.first_time:
-            print
-            print "Unconstrained grid search size: " + `grid_size` + " 
(constraints may decrease this size).\n"
+            print()
+            print("Unconstrained grid search size: " + repr(grid_size) + " 
(constraints may decrease this size).\n")
             if verbosity:
                 if verbosity >= 2:
-                    print print_prefix
-                print print_prefix
-                print print_prefix + "Grid search"
-                print print_prefix + "~~~~~~~~~~~"
+                    print(print_prefix)
+                print(print_prefix)
+                print(print_prefix + "Grid search")
+                print(print_prefix + "~~~~~~~~~~~")
 
             # Linear constraints.
             if A != None and b != None:
                 if verbosity >= 3:
-                    print print_prefix + "Linear constraint matrices."
-                    print print_prefix + "A: " + `A`
-                    print print_prefix + "b: " + `b`
+                    print(print_prefix + "Linear constraint matrices.")
+                    print(print_prefix + "A: " + repr(A))
+                    print(print_prefix + "b: " + repr(b))
 
         # we don't want to prepend the masters stdout tag
         sys.__stdout__.write('\n'+self.result_string),
@@ -114,21 +114,21 @@
         if sgm.completed:
             if verbosity and results != None:
                 if full_output:
-                    print ''
-                    print ''
-                    print print_prefix + "Parameter values: " + `sgm.xk`
-                    print print_prefix + "Function value:   " + `sgm.fk`
-                    print print_prefix + "Iterations:       " + `sgm.k`
-                    print print_prefix + "Function calls:   " + `sgm.f_count`
-                    print print_prefix + "Gradient calls:   " + `sgm.g_count`
-                    print print_prefix + "Hessian calls:    " + `sgm.h_count`
+                    print('')
+                    print('')
+                    print(print_prefix + "Parameter values: " + repr(sgm.xk))
+                    print(print_prefix + "Function value:   " + repr(sgm.fk))
+                    print(print_prefix + "Iterations:       " + repr(sgm.k))
+                    print(print_prefix + "Function calls:   " + 
repr(sgm.f_count))
+                    print(print_prefix + "Gradient calls:   " + 
repr(sgm.g_count))
+                    print(print_prefix + "Hessian calls:    " + 
repr(sgm.h_count))
                     if sgm.warning:
-                        print print_prefix + "Warning:          " + 
sgm.warning
+                        print(print_prefix + "Warning:          " + 
sgm.warning)
                     else:
-                        print print_prefix + "Warning:          None"
+                        print(print_prefix + "Warning:          None")
                 else:
-                    print print_prefix + "Parameter values: " + 
`sgm.short_results`
-                print ""
+                    print(print_prefix + "Parameter values: " + 
repr(sgm.short_results))
+                print("")
 
             m_f = sgm.model_free
             m_f.iter_count = 0
@@ -187,15 +187,15 @@
         if self.minimise_map['print_flag'] >= 1:
             # Monte Carlo simulation print out.
             if self.info_map['sim_index'] != None and self.info_map['index'] 
== 0:
-                print 'Simulation '+ `self.info_map['sim_index']`+ '\n'
+                print('Simulation '+ repr(self.info_map['sim_index'])+ '\n')
 
             # Individual spin print out.
             if self.mf_map['model_type'] == 'mf' or 
self.mf_map['model_type'] == 'local_tm':
                 if self.minimise_map['print_flag'] >= 2:
-                    print "\n\n"
+                    print("\n\n")
                 string = "Fitting to spin: " + self.info_map['spin_id']
-                print "\n\n" + string
-                print len(string) * '~'
+                print("\n\n" + string)
+                print(len(string) * '~')
 
 
 #    def do_minimise(self, memo):




Related Messages


Powered by MHonArc, Updated Thu Sep 03 15:40:04 2009