mailr10429 - /branches/bieri_gui/gui_bieri/execution/calc_modelfree.py


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

Header


Content

Posted by edward on January 27, 2010 - 11:16:
Author: bugman
Date: Wed Jan 27 11:16:22 2010
New Revision: 10429

URL: http://svn.gna.org/viewcvs/relax?rev=10429&view=rev
Log:
An additional function is added, that converts a string (such as 'xxx * e-1') 
into a float. 

This convert_string_to_float_patch file was attached to 
https://gna.org/task/?6847 by Michael
Bieri (https://gna.org/users/michaelbieri), in the zip file 
calc_modelfree.py_patch.tar.gz
(https://gna.org/support/download.php?file_id=7750).

This function is used to read in bond length or csa values set in settings 
window as float values.

The following changes were made to the patch:
    converttofloat was renamed to convert_to_float to match relax' standards,
    ''' was replaced with """ (again a relax standard),
    The single space at the start of the docstring header line was removed 
and a full stop added
        (both are needed to meet the standard),
    The docstring expanded,
    Comments were added and the lines with '######################' removed. 


Modified:
    branches/bieri_gui/gui_bieri/execution/calc_modelfree.py

Modified: branches/bieri_gui/gui_bieri/execution/calc_modelfree.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/execution/calc_modelfree.py?rev=10429&r1=10428&r2=10429&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/execution/calc_modelfree.py (original)
+++ branches/bieri_gui/gui_bieri/execution/calc_modelfree.py Wed Jan 27 
11:16:22 2010
@@ -42,6 +42,33 @@
 
 # relaxGUI module imports.
 from gui_bieri.message import relax_run_ok
+
+
+def convert_to_float(string):
+    """Method to convert a string like '1.02*1e-10' to a float variable.
+
+    @param string:  The number in string form.
+    @type string:   str
+    @return:        The floating point number.
+    @rtype:         float
+    """
+ 
+    # Break the number up.
+    entries = string.split('*')
+
+    # The first part of the number.
+    a = entries[0]
+    a = float(a)
+
+    # The second part of the number.
+    b = entries[1]
+    b = float(b[2:len(b)])
+
+    # Recombine.
+    result = a * math.pow(10, b)
+
+    # Return the float.
+    return result
 
 
 def start_model_free(self, model, automatic, global_setting, file_setting, 
sequencefile, logpanel):




Related Messages


Powered by MHonArc, Updated Wed Jan 27 11:40:02 2010