mailr4897 - in /branches/consistency_tests_1.3: ./ generic_fns/ specific_fns/ specific_fns/model_free/ test_suite/unit_tests/_ge...


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

Header


Content

Posted by sebastien . morin . 1 on January 28, 2008 - 17:56:
Author: semor
Date: Mon Jan 28 17:56:39 2008
New Revision: 4897

URL: http://svn.gna.org/viewcvs/relax?rev=4897&view=rev
Log:
Merged revisions 4854-4856,4858-4860,4886-4888 via svnmerge from 
svn+ssh://semor@xxxxxxxxxxx/svn/relax/1.3

........
  r4854 | bugman | 2008-01-18 09:42:02 -0500 (Fri, 18 Jan 2008) | 3 lines
  
  Big refactorisation of the partition_params() and set() functions.
........
  r4855 | bugman | 2008-01-18 09:58:10 -0500 (Fri, 18 Jan 2008) | 3 lines
  
  Changed the way the model parameters are set in the set() function.
........
  r4856 | bugman | 2008-01-18 10:01:28 -0500 (Fri, 18 Jan 2008) | 6 lines
  
  Reverted r4850 as generic_fns.value.partition_params() has returned to its 
previous behaviour.
  
  The command used was:
  svn merge -r4850:4849 .
........
  r4858 | semor | 2008-01-18 16:41:55 -0500 (Fri, 18 Jan 2008) | 3 lines
  
  Uniformized the format of constants.
........
  r4859 | bugman | 2008-01-21 05:15:41 -0500 (Mon, 21 Jan 2008) | 5 lines
  
  When None, the param variable is converted to a list of None with the 
length equal to that of val.
  
  This affects the generic_fns.value.set() function when no parameters are 
supplied.
........
  r4860 | bugman | 2008-01-21 05:19:40 -0500 (Mon, 21 Jan 2008) | 6 lines
  
  Reverted the last change as param needs to be passed to 
set_non_spin_params() as None.
  
  The command used was:
  svn merge -r4859:4858 .
........
  r4886 | bugman | 2008-01-25 08:13:57 -0500 (Fri, 25 Jan 2008) | 9 lines
  
  Bug fix for the generic_fns.value.set() function.
  
  The differentiation between a spin specific parameter and a global 
parameter was not working for
  specific analyses with no spin specific parameters.  The return_data_name() 
function was being used
  to differentiate, which makes no sense.  So instead the is_spin_param() 
function has been introduced
  to allow the specific code to answer the question explicitly.  Note that 
this will temporarily break
  many things.
........
  r4887 | bugman | 2008-01-25 09:31:19 -0500 (Fri, 25 Jan 2008) | 5 lines
  
  Implemented the is_spin_param() base class method.
  
  This function always returns true.
........
  r4888 | bugman | 2008-01-25 09:56:06 -0500 (Fri, 25 Jan 2008) | 3 lines
  
  Implemented the model-free specific is_spin_param() method.
........

Modified:
    branches/consistency_tests_1.3/   (props changed)
    branches/consistency_tests_1.3/generic_fns/value.py
    branches/consistency_tests_1.3/physical_constants.py
    branches/consistency_tests_1.3/specific_fns/__init__.py
    branches/consistency_tests_1.3/specific_fns/base_class.py
    branches/consistency_tests_1.3/specific_fns/model_free/model_free.py
    
branches/consistency_tests_1.3/test_suite/unit_tests/_generic_fns/test_value.py

Propchange: branches/consistency_tests_1.3/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 28 17:56:39 2008
@@ -1,1 +1,1 @@
-/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433,4440-4461,4473,4476-4493,4523-4551,4567-4577,4579,4585-4586,4618-4623,4659,4662-4693,4698-4759,4778-4792,4796-4839,4841-4850
+/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433,4440-4461,4473,4476-4493,4523-4551,4567-4577,4579,4585-4586,4618-4623,4659,4662-4693,4698-4759,4778-4792,4796-4839,4841-4850,4854-4888

Modified: branches/consistency_tests_1.3/generic_fns/value.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/generic_fns/value.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- branches/consistency_tests_1.3/generic_fns/value.py (original)
+++ branches/consistency_tests_1.3/generic_fns/value.py Mon Jan 28 17:56:39 
2008
@@ -50,21 +50,49 @@
     """
 
     # Specific functions.
-    return_data_name = get_specific_fn('return_data_name', 
relax_data_store[relax_data_store.current_pipe].pipe_type)
+    is_spin_param = get_specific_fn('is_spin_param', 
relax_data_store[relax_data_store.current_pipe].pipe_type)
 
     # Initialise.
     spin_params = []
     spin_values = []
     other_params = []
     other_values = []
-    model_values = []
-
-    # The parameter has been specified.
-    if param:
-        # Single parameter.
-        if type(param) == str:
+
+    # Single parameter.
+    if type(param) == str:
+        # Spin specific parameter.
+        if is_spin_param(param):
+            params = spin_params
+            values = spin_values
+
+        # Other parameters.
+        else:
+            params = other_params
+            values = other_values
+
+        # List of values.
+        if type(val) == list or isinstance(val, ndarray):
+            # Parameter name.
+            for i in xrange(len(val)):
+                params.append(param)
+
+            # Parameter value.
+            values = val
+
+        # Single value.
+        else:
+            # Parameter name.
+            params.append(param)
+
+            # Parameter value.
+            values.append(val)
+
+    # Multiple parameters.
+    elif type(param) == list:
+        # Loop over all parameters.
+        for i in xrange(len(param)):
             # Spin specific parameter.
-            if return_data_name(param):
+            if is_spin_param(param[i]):
                 params = spin_params
                 values = spin_values
 
@@ -73,59 +101,18 @@
                 params = other_params
                 values = other_values
 
-            # List of values.
+            # Parameter name.
+            params.append(param[i])
+
+            # Parameter value.
             if type(val) == list or isinstance(val, ndarray):
-                # Parameter name.
-                for i in xrange(len(val)):
-                    params.append(param)
-
-                # Parameter value.
-                values = val
-
-            # Single value.
+                values.append(val[i])
             else:
-                # Parameter name.
-                params.append(param)
-
-                # Parameter value.
                 values.append(val)
 
-        # Multiple parameters.
-        elif type(param) == list:
-            # Loop over all parameters.
-            for i in xrange(len(param)):
-                # Spin specific parameter.
-                if return_data_name(param[i]):
-                    params = spin_params
-                    values = spin_values
-
-                # Other parameters.
-                else:
-                    params = other_params
-                    values = other_values
-
-                # Parameter name.
-                params.append(param[i])
-
-                # Parameter value.
-                if type(val) == list or isinstance(val, ndarray):
-                    values.append(val[i])
-                else:
-                    values.append(val)
-
-
-    # No parameter name supplied, so these must be the model parameter 
values.
-    else:
-        # List of values.
-        if type(val) == list or isinstance(val, ndarray):
-            model_values = val
-
-        # Single value.
-        elif val:
-            model_values = [val]
 
     # Return the partitioned parameters and values.
-    return spin_params, spin_values, other_params, other_values, model_values
+    return spin_params, spin_values, other_params, other_values
 
 
 def set(val=None, param=None, spin_id=None, force=False):
@@ -149,52 +136,70 @@
     return_value = get_specific_fn('return_value', 
relax_data_store[relax_data_store.current_pipe].pipe_type)
     set_non_spin_params = get_specific_fn('set_non_spin_params', 
relax_data_store[relax_data_store.current_pipe].pipe_type)
 
-    # Partition the parameters into those which are spin specific and those 
which are not.
-    spin_params, spin_values, other_params, other_values, model_values = 
partition_params(val, param)
-
-
-    # Spin specific parameters.
-    ###########################
-
-    if spin_params:
-        # Test if the sequence data is loaded.
-        if not exists_mol_res_spin_data():
-            raise RelaxNoSequenceError
-
-        # First test if parameter value already exists, prior to setting any 
params.
-        if not force:
+    # The parameters have been specified.
+    if param:
+        # Partition the parameters into those which are spin specific and 
those which are not.
+        spin_params, spin_values, other_params, other_values = 
partition_params(val, param)
+
+        # Spin specific parameters.
+        if spin_params:
+            # Test if the sequence data is loaded.
+            if not exists_mol_res_spin_data():
+                raise RelaxNoSequenceError
+
+            # First test if parameter value already exists, prior to setting 
any params.
+            if not force:
+                # Loop over the spins.
+                for spin in spin_loop(spin_id):
+                    # Skip unselected spins.
+                    if not spin.select:
+                        continue
+
+                    # Loop over the parameters.
+                    for param in spin_params:
+                        # Get the value and error.
+                        temp_value, temp_error = return_value(spin, param)
+
+                        # Data exists.
+                        if temp_value != None or temp_error != None:
+                            raise RelaxValueError, (param)
+
+            # Loop over the spins.
+            for spin in spin_loop(spin_id):
+                # Skip unselected residues.
+                if not spin.select:
+                    continue
+
+                # Set the individual parameter values.
+                for j in xrange(len(spin_params)):
+                    set_spin_params(value=spin_values[j], error=None, 
spin=spin, param=spin_params[j])
+
+
+        # All other parameters.
+        if other_params:
+            set_non_spin_params(value=other_values, param=other_params)
+
+
+    # All model parameters (i.e. no parameters have been supplied).
+    else:
+        # Convert val to a list if necessary.
+        if type(val) != list or not isinstance(val, ndarray):
+            val = [val]
+
+        # Spin specific models.
+        if exists_mol_res_spin_data():
             # Loop over the spins.
             for spin in spin_loop(spin_id):
                 # Skip unselected spins.
                 if not spin.select:
                     continue
 
-                # Loop over the parameters.
-                for param in spin_params:
-                    # Get the value and error.
-                    temp_value, temp_error = return_value(spin, param)
-
-                    # Data exists.
-                    if temp_value != None or temp_error != None:
-                        raise RelaxValueError, (param)
-
-        # Loop over the spins.
-        for spin in spin_loop(spin_id):
-            # Skip unselected residues.
-            if not spin.select:
-                continue
-
-            # Go to the specific code.
-            for j in xrange(len(spin_params)):
-                set_spin_params(value=spin_values[j], error=None, spin=spin, 
param=spin_params[j])
-
-
-    # All other parameters.
-    #######################
-
-    if other_params:
-        set_non_spin_params(value=other_values, param=other_params)
-
+                # Set the individual parameter values.
+                for j in xrange(len(val)):
+                    set_spin_params(value=val[j], error=None, spin=spin, 
param=None)
+
+        # Set the non-spin specific parameters.
+        set_non_spin_params(value=val, param=param)
 
     # Reset all minimisation statistics.
     reset_min_stats()

Modified: branches/consistency_tests_1.3/physical_constants.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/physical_constants.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- branches/consistency_tests_1.3/physical_constants.py (original)
+++ branches/consistency_tests_1.3/physical_constants.py Mon Jan 28 17:56:39 
2008
@@ -25,10 +25,10 @@
 
 
 # Planck's constant.
-h = 6.62606876e-34
+h = 6.62606876 * 1e-34
 
 # Dirac's constant.
-h_bar = h / (2.0*pi)
+h_bar = h / (2.0 * pi)
 
 # The magnetic constant or the permeability of vacuum.
 mu0 = 4.0 * pi * 1e-7
@@ -41,16 +41,16 @@
 
 
 # The 13C gyromagnetic ratio.
-g13C = 6.728e7
+g13C = 6.728 * 1e7
 
 # The 1H gyromagnetic ratio.
-g1H = 26.7522212e7
+g1H = 26.7522212 * 1e7
 
 # The 15N gyromagnetic ratio.
-g15N = -2.7126e7
+g15N = -2.7126 * 1e7
 
 # The 17O gyromagnetic ratio.
-g17O = -3.628e7
+g17O = -3.628 * 1e7
 
 # The 31P gyromagnetic ratio.
-g31P = 1.0841e8
+g31P = 10.841 * 1e7

Modified: branches/consistency_tests_1.3/specific_fns/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/__init__.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- branches/consistency_tests_1.3/specific_fns/__init__.py (original)
+++ branches/consistency_tests_1.3/specific_fns/__init__.py Mon Jan 28 
17:56:39 2008
@@ -106,6 +106,10 @@
         if eqi == 'init_sim_values':
             function = inst.sim_init_values
 
+        # Spin specific parameter determining function.
+        if eqi == 'is_spin_param':
+            function = inst.is_spin_param
+
         # Map bounds function.
         if eqi == 'map_bounds':
             function = inst.map_bounds

Modified: branches/consistency_tests_1.3/specific_fns/base_class.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/base_class.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- branches/consistency_tests_1.3/specific_fns/base_class.py (original)
+++ branches/consistency_tests_1.3/specific_fns/base_class.py Mon Jan 28 
17:56:39 2008
@@ -66,6 +66,22 @@
 
         # No errors found.
         return False
+
+
+    def is_spin_param(self, name):
+        """Determine whether the given parameter is spin specific.
+
+        This base class method always returns true, hence all parameters 
will be considered
+        residents of a SpinContainer object unless this method is 
overwritten.
+
+        @param name:    The name of the parameter.
+        @type name:     str
+        @return:        True
+        @rtype:         bool
+        """
+
+        # Return the default of True.
+        return True
 
 
     def num_instances(self):

Modified: branches/consistency_tests_1.3/specific_fns/model_free/model_free.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/model_free/model_free.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- branches/consistency_tests_1.3/specific_fns/model_free/model_free.py 
(original)
+++ branches/consistency_tests_1.3/specific_fns/model_free/model_free.py Mon 
Jan 28 17:56:39 2008
@@ -1074,6 +1074,27 @@
 
         # Return the parameter names.
         return self.param_vector
+
+
+    def is_spin_param(self, name):
+        """Determine whether the given parameter is spin specific.
+
+        Unless a diffusion parameter is encountered, this method will return 
true.
+
+        @param name:    The name of the parameter.
+        @type name:     str
+        @return:        If the parameter is a diffusion parameter, False I 
returned.  Otherwise True
+                        is returned.
+        @rtype:         bool
+        """
+
+        # Catch a diffusion parameter.
+        if diffusion_tensor.return_data_name(name):
+            return False
+
+        # All the rest:
+        else:
+            return True
 
 
     def linear_constraints(self, index=None):

Modified: 
branches/consistency_tests_1.3/test_suite/unit_tests/_generic_fns/test_value.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/test_suite/unit_tests/_generic_fns/test_value.py?rev=4897&r1=4896&r2=4897&view=diff
==============================================================================
--- 
branches/consistency_tests_1.3/test_suite/unit_tests/_generic_fns/test_value.py
 (original)
+++ 
branches/consistency_tests_1.3/test_suite/unit_tests/_generic_fns/test_value.py
 Mon Jan 28 17:56:39 2008
@@ -48,7 +48,7 @@
         val = [0.8]
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, ['S2'])
@@ -68,7 +68,7 @@
         val = [1e7]
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, [])
@@ -88,7 +88,7 @@
         val = [1e7, 0.8]
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, ['S2'])
@@ -108,7 +108,7 @@
         val = [1e7, 0.8, -160e-6]
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, ['S2', 'CSA'])
@@ -128,7 +128,7 @@
         val = [1e7, 0.8, 2e7, -160e-6, 0.13]
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, ['S2', 'CSA'])
@@ -148,7 +148,7 @@
         val = []
 
         # Partition.
-        spin_params, spin_values, other_params, other_values, model_values = 
value.partition_params(val, param)
+        spin_params, spin_values, other_params, other_values = 
value.partition_params(val, param)
 
         # Tests.
         self.assertEqual(spin_params, [])




Related Messages


Powered by MHonArc, Updated Mon Jan 28 18:00:16 2008