mailr2894 - in /1.3: generic_fns/monte_carlo.py specific_fns/model_free.py


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

Header


Content

Posted by edward on November 30, 2006 - 10:00:
Author: bugman
Date: Thu Nov 30 09:59:47 2006
New Revision: 2894

URL: http://svn.gna.org/viewcvs/relax?rev=2894&view=rev
Log:
Fix for bug #7755 (https://gna.org/bugs/?7755).

This bug was reported by Stephen Headey (https://gna.org/users/sjheadey).

The problem was that the select_sim array created by the columnar results 
reading function
'self.read_columnar_results()' in 'specific_fns/model_free.py' was one 
massive single array
containing all the selected simulation data of all spin systems of all 
simulations.  Subsequently
this was then not being split up for each spin system.  Hence the total 
number of simulations was
being set to the number of spin systems times the number of simulations.  The 
select_sim array for
each spin system was also of the same length and contained the data for all 
spins.

The fix was to convert the 'select_sim' array being created by 
'self.read_columnar_results()' into
a Numeric matrix.  The first dimension corresponds to the simulation and the 
second corresponds to
the instance.


Modified:
    1.3/generic_fns/monte_carlo.py
    1.3/specific_fns/model_free.py

Modified: 1.3/generic_fns/monte_carlo.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/monte_carlo.py?rev=2894&r1=2893&r2=2894&view=diff
==============================================================================
--- 1.3/generic_fns/monte_carlo.py (original)
+++ 1.3/generic_fns/monte_carlo.py Thu Nov 30 09:59:47 2006
@@ -22,6 +22,7 @@
 
 from copy import deepcopy
 from math import sqrt
+from Numeric import ones
 from random import gauss
 
 
@@ -321,18 +322,32 @@
 
         # Create the selected simulation array with all simulations selected.
         if select_sim == None:
-            select_sim = []
-            for i in xrange(number):
-                select_sim.append(1)
+            all_selected = ones(number)
 
         # Loop over the instances.
         for instance in xrange(num_instances):
+            # Set up the selected simulation array.
+            if select_sim == None:
+                selected_sims = all_selected
+            else:
+                selected_sims = select_sim[instance].tolist()
+
             # Set the selected simulation array.
-            set_selected_sim(self.run, instance, select_sim)
+            set_selected_sim(self.run, instance, selected_sims)
 
 
     def setup(self, run=None, number=None, select_sim=None):
-        """Function for setting up Monte Carlo simulations."""
+        """Function for setting up Monte Carlo simulations.
+        
+        @param run:         The name of the run.
+        @type run:          str
+        @param number:      The number of Monte Carlo simulations to set up.
+        @type number:       int
+        @params select_sim: The selection status of the Monte Carlo 
simulations.  The first
+            dimension of this matrix corresponds to the simulation and the 
second corresponds to the
+            instance.
+        @type select_sim:   Numeric matrix (int)
+        """
 
         # Arguments.
         self.run = run
@@ -350,10 +365,7 @@
             self.relax.data.sim_number = {}
 
         # Add the simulation number.
-        if select_sim:
-            self.relax.data.sim_number[self.run] = len(select_sim)
-        else:
-            self.relax.data.sim_number[self.run] = number
+        self.relax.data.sim_number[self.run] = number
 
         # Create the data structure 'sim_state'.
         if not hasattr(self.relax.data, 'sim_state'):

Modified: 1.3/specific_fns/model_free.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free.py?rev=2894&r1=2893&r2=2894&view=diff
==============================================================================
--- 1.3/specific_fns/model_free.py (original)
+++ 1.3/specific_fns/model_free.py Thu Nov 30 09:59:47 2006
@@ -3391,11 +3391,14 @@
                 except:
                     raise RelaxError, "The simulation number '%s' is 
invalid." % sim_num
 
-                # Update the sims array.
-                sims.append(sim_num)
+                # A new simulation number.
+                if sim_num not in sims:
+                    # Update the sims array and append an empty array to the 
selected sims array.
+                    sims.append(sim_num)
+                    select_sim.append([])
 
                 # Selected simulations.
-                select_sim.append(self.file_line[self.col['select']])
+                
select_sim[-1].append(int(self.file_line[self.col['select']]))
 
             # Diffusion tensor data.
             if self.data_set == 'value' and not diff_data_set:
@@ -3433,7 +3436,11 @@
 
         # Set up the simulations.
         if len(sims):
-            self.relax.generic.monte_carlo.setup(self.run, 
select_sim=select_sim)
+            # Convert the selected simulation array of arrays into a Numeric 
matrix and transpose it.
+            select_sim = transpose(array(select_sim))
+
+            # Set up the Monte Carlo simulations.
+            self.relax.generic.monte_carlo.setup(self.run, number=len(sims), 
select_sim=select_sim)
 
 
     def read_columnar_sequence(self):




Related Messages


Powered by MHonArc, Updated Thu Nov 30 10:40:07 2006