mailr19615 - /trunk/lib/mathematics.py


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

Header


Content

Posted by edward on May 02, 2013 - 12:40:
Author: bugman
Date: Thu May  2 12:40:30 2013
New Revision: 19615

URL: http://svn.gna.org/viewcvs/relax?rev=19615&view=rev
Log:
Bug fixes for the lib.mathematics module as found by the unit tests.


Modified:
    trunk/lib/mathematics.py

Modified: trunk/lib/mathematics.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/mathematics.py?rev=19615&r1=19614&r2=19615&view=diff
==============================================================================
--- trunk/lib/mathematics.py (original)
+++ trunk/lib/mathematics.py Thu May  2 12:40:30 2013
@@ -23,20 +23,23 @@
 """Module for basic mathematical operations."""
 
 # Python module imports.
-from math import floor, log10
+from math import ceil, log10
 
 
 def order_of_magnitude(value):
     """Determine the order of magnitude of the given number.
 
+    For example, the number 1,234 will be give a value of 4.0.
+
+
     @param value:   The value to determine the order of magnitude of.
     @type value:    float or int
     @return:        The order of magnitude.
-    @rtype:         int
+    @rtype:         float
     """
 
     # Calculate and return the value.
-    return floor(log10(x))
+    return ceil(log10(value))
 
 
 def round_to_next_order(value):
@@ -52,4 +55,4 @@
     """
     
     # Calculate and return the value.
-    return 10**(order_of_magnitude(value) + 1)
+    return 10**(order_of_magnitude(value))




Related Messages


Powered by MHonArc, Updated Thu May 02 13:00:02 2013