mailr22712 - in /trunk: pipe_control/ specific_analyses/ specific_analyses/model_free/ specific_analyses/n_state_model/


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

Header


Content

Posted by edward on April 11, 2014 - 10:35:
Author: bugman
Date: Fri Apr 11 10:35:18 2014
New Revision: 22712

URL: http://svn.gna.org/viewcvs/relax?rev=22712&view=rev
Log:
Eliminated the return_data_name() concept from the specific analysis API.

The parameter names can now only have one value, i.e. 's2' is different from 
'S2'.  In addition, a
number of related functions have been deleted form the pipe_control.minimise 
module as these are now
handled by the parameter list object.  The deleted functions are 
return_conversion_factor() and
return_value().


Modified:
    trunk/pipe_control/minimise.py
    trunk/pipe_control/opendx.py
    trunk/pipe_control/plotting.py
    trunk/pipe_control/value.py
    trunk/specific_analyses/api_base.py
    trunk/specific_analyses/api_common.py
    trunk/specific_analyses/model_free/api.py
    trunk/specific_analyses/n_state_model/api.py

Modified: trunk/pipe_control/minimise.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/minimise.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/pipe_control/minimise.py      (original)
+++ trunk/pipe_control/minimise.py      Fri Apr 11 10:35:18 2014
@@ -319,18 +319,6 @@
             spin.warning = None
 
 
-def return_conversion_factor(stat_type):
-    """Dummy function for returning 1.0.
-
-    @param stat_type:   The name of the statistic.  This is unused!
-    @type stat_type:    str
-    @return:            A conversion factor of 1.0.
-    @rtype:             float
-    """
-
-    return 1.0
-
-
 return_data_name_doc = Desc_container("Minimisation statistic data type 
string matching patterns")
 table = uf_tables.add_table(label="table: min data type patterns", 
caption="Minimisation statistic data type string matching patterns.")
 table.add_headings(["Data type", "Object name", "Patterns"])
@@ -341,93 +329,6 @@
 table.add_row(["Hessian call count", "'h_count'", "'^[Hh].*[ -_][Cc]ount'"])
 return_data_name_doc.add_table(table.label)
 
-def return_data_name(name):
-    """Return a unique identifying string for the minimisation parameter.
-
-    @param name:    The minimisation parameter.
-    @type name:     str
-    @return:        The unique parameter identifying string.
-    @rtype:         str
-    """
-
-    # Chi-squared.
-    if search('^[Cc]hi2$', name) or search('^[Cc]hi[-_ ][Ss]quare', name):
-        return 'chi2'
-
-    # Iteration count.
-    if search('^[Ii]ter', name):
-        return 'iter'
-
-    # Function call count.
-    if search('^[Ff].*[ -_][Cc]ount', name):
-        return 'f_count'
-
-    # Gradient call count.
-    if search('^[Gg].*[ -_][Cc]ount', name):
-        return 'g_count'
-
-    # Hessian call count.
-    if search('^[Hh].*[ -_][Cc]ount', name):
-        return 'h_count'
-
-
-def return_value(spin=None, stat_type=None, sim=None):
-    """Function for returning the minimisation statistic corresponding to 
'stat_type'.
-
-    @param spin:        The spin data container if spin specific data is to 
be reset.
-    @type spin:         SpinContainer
-    @param stat_type:   The name of the statistic to return the value for.
-    @type stat_type:    str
-    @param sim:         The index of the simulation to return the value for. 
 If None, then the
-                        normal value is returned.
-    @type sim:          None or int
-    """
-
-    # Get the object name.
-    object_name = return_data_name(stat_type)
-
-    # The statistic type does not exist.
-    if not object_name:
-        raise RelaxError("The statistic type " + repr(stat_type) + " does 
not exist.")
-
-    # The simulation object name.
-    object_sim = object_name + '_sim'
-
-    # Get the global statistic.
-    if spin == None:
-        # Get the statistic.
-        if sim == None:
-            if hasattr(cdp, object_name):
-                stat = getattr(cdp, object_name)
-            else:
-                stat = None
-
-        # Get the simulation statistic.
-        else:
-            if hasattr(cdp, object_sim):
-                stat = getattr(cdp, object_sim)[sim]
-            else:
-                stat = None
-
-    # Residue specific statistic.
-    else:
-        # Get the statistic.
-        if sim == None:
-            if hasattr(spin, object_name):
-                stat = getattr(spin, object_name)
-            else:
-                stat = None
-
-        # Get the simulation statistic.
-        else:
-            if hasattr(spin, object_sim):
-                stat = getattr(spin, object_sim)[sim]
-            else:
-                stat = None
-
-    # Return the statistic (together with None to indicate that there are no 
errors associated with the statistic).
-    return stat, None
-
 
 set_doc = """
         Minimisation statistic set details
@@ -449,29 +350,26 @@
     @type spin_id:      str
     """
 
-    # Get the parameter name.
-    param_name = return_data_name(param)
-
     # Global minimisation stats.
     if spin_id == None:
         # Chi-squared.
-        if param_name == 'chi2':
+        if param == 'chi2':
             cdp.chi2 = val
 
         # Iteration count.
-        elif param_name == 'iter':
+        elif param == 'iter':
             cdp.iter = val
 
         # Function call count.
-        elif param_name == 'f_count':
+        elif param == 'f_count':
             cdp.f_count = val
 
         # Gradient call count.
-        elif param_name == 'g_count':
+        elif param == 'g_count':
             cdp.g_count = val
 
         # Hessian call count.
-        elif param_name == 'h_count':
+        elif param == 'h_count':
             cdp.h_count = val
 
     # Residue specific minimisation.
@@ -480,21 +378,21 @@
         spin = return_spin(spin_id)
 
         # Chi-squared.
-        if param_name == 'chi2':
+        if param == 'chi2':
             spin.chi2 = val
 
         # Iteration count.
-        elif param_name == 'iter':
+        elif param == 'iter':
             spin.iter = val
 
         # Function call count.
-        elif param_name == 'f_count':
+        elif param == 'f_count':
             spin.f_count = val
 
         # Gradient call count.
-        elif param_name == 'g_count':
+        elif param == 'g_count':
             spin.g_count = val
 
         # Hessian call count.
-        elif param_name == 'h_count':
+        elif param == 'h_count':
             spin.h_count = val

Modified: trunk/pipe_control/opendx.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/opendx.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/pipe_control/opendx.py        (original)
+++ trunk/pipe_control/opendx.py        Fri Apr 11 10:35:18 2014
@@ -119,7 +119,6 @@
         # Alias the specific functions.
         self.calculate = api.calculate
         self.model_statistics = api.model_statistics
-        self.return_data_name = api.return_data_name
         self.map_bounds = []
         self.return_conversion_factor = []
         self.return_units = []
@@ -230,8 +229,8 @@
 
         # Loop over the parameters.
         for i in range(self.n):
-            # Get the parameter name.
-            name = self.return_data_name(self.params[i])
+            # Alias the parameter name.
+            name = self.params[i]
 
             # Diffusion tensor parameter.
             if pipes.get_type() == 'mf':

Modified: trunk/pipe_control/plotting.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/plotting.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/pipe_control/plotting.py      (original)
+++ trunk/pipe_control/plotting.py      Fri Apr 11 10:35:18 2014
@@ -28,7 +28,6 @@
 
 # relax module imports.
 from lib.errors import RelaxError
-from pipe_control import minimise
 from pipe_control.mol_res_spin import spin_loop
 from specific_analyses.api import return_api
 
@@ -610,10 +609,6 @@
     if data_name in ['res_num', 'spin_num']:
         return None, None
 
-    # A minimisation statistic.
-    if minimise.return_data_name(data_name):
-        return minimise.return_value, minimise.return_conversion_factor
-
     # Analysis specific value returning functions.
     else:
         api = return_api()
@@ -633,11 +628,6 @@
     if data_name in ['res_num', 'spin_num']:
         return int
 
-    # A minimisation statistic.
-    if minimise.return_data_name(data_name):
-        return int
-
     # Analysis specific value returning functions.
-    else:
-        api = return_api()
-        return api.data_type(data_name)
+    api = return_api()
+    return api.data_type(data_name)

Modified: trunk/pipe_control/value.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/value.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/pipe_control/value.py (original)
+++ trunk/pipe_control/value.py Fri Apr 11 10:35:18 2014
@@ -282,19 +282,6 @@
     if not exists_mol_res_spin_data():
         raise RelaxNoSequenceError
 
-    # Minimisation parameter.
-    if minimise.return_data_name(param):
-        # Minimisation statistic flag.
-        min_stat = True
-
-        # Specific value and error returning function.
-        return_value = minimise.return_value
-
-        # Specific set function.
-        set_fn = minimise.set
-
-    # Normal parameter.
-    else:
         # Minimisation statistic flag.
         min_stat = False
 
@@ -354,7 +341,7 @@
     write_spin_data(file=sys.stdout, mol_names=mol_names, res_nums=res_nums, 
res_names=res_names, spin_nums=spin_nums, spin_names=spin_names, data=values, 
data_name=param, error=errors, error_name='%s_error'%param)
 
     # Reset the minimisation statistics.
-    if not min_stat:
+    if api.set(param) == 'min':
         minimise.reset_min_stats()
 
 
@@ -421,7 +408,7 @@
         # Loop over the parameters, getting the default values.
         val = []
         for i in range(len(param)):
-            val.append(api.default_value(api.return_data_name(param[i])))
+            val.append(api.default_value(param[i]))
 
             # Check that there is a default.
             if val[-1] == None:

Modified: trunk/specific_analyses/api_base.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/api_base.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/specific_analyses/api_base.py (original)
+++ trunk/specific_analyses/api_base.py Fri Apr 11 10:35:18 2014
@@ -552,23 +552,6 @@
         return self._PARAMS.description(name)
 
 
-    def return_data_name(self, param):
-        """Return a unique identifying string for the given parameter.
-
-        @param param:   The parameter name.
-        @type param:    str
-        @return:        The unique parameter identifying string.
-        @rtype:         str
-        """
-
-        # No parameter.
-        if not self._PARAMS.contains(param):
-            return None
-
-        # Return the name.
-        return param
-
-
     def return_error(self, data_id=None):
         """Return the error points corresponding to the data points used in 
optimisation.
 

Modified: trunk/specific_analyses/api_common.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/api_common.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/specific_analyses/api_common.py       (original)
+++ trunk/specific_analyses/api_common.py       Fri Apr 11 10:35:18 2014
@@ -383,21 +383,18 @@
         # Initialise.
         index = None
 
-        # Get the object name.
-        object_name = self.return_data_name(param)
-
         # The error, simulation and back calculated names.
-        if object_name:
-            object_error = object_name + '_err'
-            object_sim = object_name + '_sim'
-            object_bc = object_name + '_bc'
+        if param:
+            object_error = param + '_err'
+            object_sim = param + '_sim'
+            object_bc = param + '_bc'
             key = None
 
         # The data type does not exist.
         else:
             # Is it a spectrum id?
             if hasattr(cdp, 'spectrum_ids') and param in cdp.spectrum_ids:
-                object_name = 'intensity'
+                param = 'intensity'
                 object_error = 'intensity_err'
                 object_sim = 'intensity_sim'
                 object_bc = 'intensity_bc'
@@ -413,23 +410,23 @@
 
         # Switch to back calculated data.
         if bc:
-            object_name = object_bc
+            param = object_bc
 
         # Value or sim value?
         if sim != None:
-            object_name = object_sim
+            param = object_sim
 
         # The spin value.
-        if hasattr(spin, object_name):
-            value = getattr(spin, object_name)
+        if hasattr(spin, param):
+            value = getattr(spin, param)
 
         # The spin error.
         if hasattr(spin, object_error):
             error = getattr(spin, object_error)
 
         # The global value.
-        elif hasattr(cdp, object_name):
-            value = getattr(cdp, object_name)
+        elif hasattr(cdp, param):
+            value = getattr(cdp, param)
 
             # The error.
             if hasattr(cdp, object_error):
@@ -517,23 +514,20 @@
 
         # Loop over the parameters.
         for i in range(len(param)):
-            # Get the object's name.
-            obj_name = self.return_data_name(param[i])
-
             # Is the parameter is valid?
-            if not obj_name:
+            if not param[i]:
                 raise RelaxError("The parameter '%s' is not valid for this 
data pipe type." % param[i])
 
             # Error object.
             if error:
-                obj_name += '_err'
+                param[i] += '_err'
 
             # Is the parameter already set.
-            if not force and hasattr(cdp, obj_name) and getattr(cdp, 
obj_name) != None:
+            if not force and hasattr(cdp, param[i]) and getattr(cdp, 
param[i]) != None:
                 raise RelaxError("The parameter '%s' already exists, set the 
force flag to True to overwrite." % param[i])
 
             # Set the parameter.
-            setattr(cdp, obj_name, value[i])
+            setattr(cdp, param[i], value[i])
 
 
     def _set_param_values_spin(self, param=None, value=None, index=None, 
spin_id=None, error=False, force=True):

Modified: trunk/specific_analyses/model_free/api.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/model_free/api.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/specific_analyses/model_free/api.py   (original)
+++ trunk/specific_analyses/model_free/api.py   Fri Apr 11 10:35:18 2014
@@ -1921,20 +1921,17 @@
 
         # Set the model-free parameters.
         for i in range(len(mf_params)):
-            # The object name.
-            obj_name = self.return_data_name(mf_params[i])
-
             # Check if it is a model-free parameter.
-            if obj_name not in self.data_names(set='params', scope='spin') 
and obj_name not in self.data_names(set='generic', scope='spin'):
+            if mf_params[i] not in self.data_names(set='params', 
scope='spin') and mf_params[i] not in self.data_names(set='generic', 
scope='spin'):
                 raise RelaxError("The parameter '%s' is unknown.  It should 
be one of %s or %s" % (mf_params[i], self.data_names(set='params', 
scope='spin'), self.data_names(set='generic', scope='spin')))
 
             # The error object name.
             if error:
-                obj_name += '_err'
+                mf_params[i] += '_err'
 
             # Set the parameter.
             for spin in spin_loop(spin_id):
-                setattr(spin, obj_name, mf_vals[i])
+                setattr(spin, mf_params[i], mf_vals[i])
 
 
     def set_selected_sim(self, model_info, select_sim):

Modified: trunk/specific_analyses/n_state_model/api.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/n_state_model/api.py?rev=22712&r1=22711&r2=22712&view=diff
==============================================================================
--- trunk/specific_analyses/n_state_model/api.py        (original)
+++ trunk/specific_analyses/n_state_model/api.py        Fri Apr 11 10:35:18 
2014
@@ -758,28 +758,23 @@
 
         # Loop over the parameters.
         for i in range(len(param)):
-            # Get the object's name.
-            obj_name = self.return_data_name(param[i])
-            print param
-            print obj_name
-
             # Is the parameter is valid?
-            if not obj_name:
+            if not param[i]:
                 raise RelaxError("The parameter '%s' is not valid for this 
data pipe type." % param[i])
 
             # Error object.
             if error:
-                obj_name += '_err'
+                param[i] += '_err'
 
             # Set the indexed parameter.
-            if obj_name in ['probs', 'alpha', 'beta', 'gamma']:
-                obj = getattr(cdp, obj_name)
+            if param[i] in ['probs', 'alpha', 'beta', 'gamma']:
+                obj = getattr(cdp, param[i])
                 obj[index] = value[i]
 
             # Set the spin parameters.
             else:
                 for spin in spin_loop(spin_id):
-                    setattr(spin, obj_name, value[i])
+                    setattr(spin, param[i], value[i])
 
 
     def sim_init_values(self):




Related Messages


Powered by MHonArc, Updated Fri Apr 11 12:00:02 2014