mailr15337 - in /branches/frame_order_testing: ./ arg_check.py relax_io.py


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

Header


Content

Posted by edward on February 15, 2012 - 11:03:
Author: bugman
Date: Wed Feb 15 11:03:33 2012
New Revision: 15337

URL: http://svn.gna.org/viewcvs/relax?rev=15337&view=rev
Log:
Merged revisions 15334-15335 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r15334 | bugman | 2012-02-15 10:58:37 +0100 (Wed, 15 Feb 2012) | 5 lines
  
  Created the SplitIO.flush() method so that a flush() call now works with 
the -t and -l command line args.
  
  This simply calls the flush() methods of both streams.
........
  r15335 | bugman | 2012-02-15 11:00:24 +0100 (Wed, 15 Feb 2012) | 3 lines
  
  The float arg checks now check against all the numpy float types (float16, 
float32, float64, float128).
........

Modified:
    branches/frame_order_testing/   (props changed)
    branches/frame_order_testing/arg_check.py
    branches/frame_order_testing/relax_io.py

Propchange: branches/frame_order_testing/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Feb 15 11:03:33 2012
@@ -1,1 +1,1 @@
-/1.3:1-15326
+/1.3:1-15336

Modified: branches/frame_order_testing/arg_check.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/arg_check.py?rev=15337&r1=15336&r2=15337&view=diff
==============================================================================
--- branches/frame_order_testing/arg_check.py (original)
+++ branches/frame_order_testing/arg_check.py Wed Feb 15 11:03:33 2012
@@ -24,12 +24,39 @@
 """Argument checking functions for the relax user functions."""
 
 # Python module imports.
-from numpy import ndarray
+from numpy import float16, float32, float64, float128, ndarray
 
 # relax module imports.
 from relax_errors import RelaxBoolError, RelaxFloatError, 
RelaxFunctionError, RelaxIntError, RelaxIntListIntError, RelaxListFloatError, 
RelaxListIntError, RelaxMatrixFloatError, RelaxNoneFloatError, 
RelaxNoneFunctionError, RelaxListNumError, RelaxListStrError, RelaxNoneError, 
RelaxNoneIntError, RelaxNoneIntListIntError, RelaxNoneListFloatError, 
RelaxNoneListIntError, RelaxNoneMatrixFloatError, RelaxNoneListNumError, 
RelaxNoneListStrError, RelaxNoneNumError, RelaxNoneNumStrListNumStrError, 
RelaxNoneNumTupleNumError, RelaxNoneStrError, RelaxNoneStrFileError, 
RelaxNoneStrListNumError, RelaxNoneStrListStrError, RelaxNumError, 
RelaxNumStrListNumStrError, RelaxNumTupleNumError, RelaxStrError, 
RelaxStrFileError, RelaxStrListNumError, RelaxStrListStrError, 
RelaxTupleError, RelaxTupleNumError
 from relax_io import DummyFileObject
 from types import FunctionType, MethodType
+
+
+def check_float(num):
+    """Check if the given number is a Python or numpy float.
+
+    @param num: The number to check.
+    @type num:  anything.
+    @return:    True if the number is a float, False otherwise.
+    @rtype:     bool
+    """
+
+    # Standard float.
+    if isinstance(num, float):
+        return True
+
+    # Numpy floats.
+    if isinstance(num, float16):
+        return True
+    if isinstance(num, float32):
+        return True
+    if isinstance(num, float64):
+        return True
+    if isinstance(num, float128):
+        return True
+
+    # Not a float.
+    return False
 
 
 def is_bool(arg, name):
@@ -72,7 +99,7 @@
         return
 
     # Check for a float.
-    if isinstance(arg, float):
+    if check_float(arg):
         return
 
     # Fail.
@@ -116,7 +143,7 @@
     else:
         for i in range(len(arg)):
             # Fail if not a float.
-            if not isinstance(arg[i], float):
+            if not check_float(arg[i]):
                 fail = True
 
     # Fail.
@@ -174,7 +201,7 @@
 
             # Check for float elements.
             for j in range(len(arg[i])):
-                if not isinstance(arg[i][j], float):
+                if not check_float(arg[i][j]):
                     fail = True
 
     # Fail.
@@ -463,7 +490,7 @@
         return
 
     # Check for floats and integers (avoiding Booleans).
-    if (isinstance(arg, float) or isinstance(arg, int)) and not 
isinstance(arg, bool):
+    if (check_float(arg) or isinstance(arg, int)) and not isinstance(arg, 
bool):
         return
 
     # Fail.
@@ -513,7 +540,7 @@
 
         # Fail if not numbers.
         for i in range(len(arg)):
-            if (not isinstance(arg[i], float) and not isinstance(arg[i], 
int)) or isinstance(arg, bool):
+            if (not check_float(arg[i]) and not isinstance(arg[i], int)) or 
isinstance(arg, bool):
                 fail = True
 
     # Fail.
@@ -574,7 +601,7 @@
 
         # Fail if not numbers.
         for i in range(len(arg)):
-            if (not isinstance(arg[i], float) and not isinstance(arg[i], 
int)) or isinstance(arg, bool):
+            if (not check_float(arg[i]) and not isinstance(arg[i], int)) or 
isinstance(arg, bool):
                 fail = True
 
     # Fail.
@@ -629,7 +656,7 @@
 
         # Fail if not numbers.
         for i in range(len(arg)):
-            if (not isinstance(arg[i], float) and not isinstance(arg[i], 
int)) or isinstance(arg, bool):
+            if (not check_float(arg[i]) and not isinstance(arg[i], int)) or 
isinstance(arg, bool):
                 fail = True
 
     # Fail.

Modified: branches/frame_order_testing/relax_io.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/relax_io.py?rev=15337&r1=15336&r2=15337&view=diff
==============================================================================
--- branches/frame_order_testing/relax_io.py (original)
+++ branches/frame_order_testing/relax_io.py Wed Feb 15 11:03:33 2012
@@ -1005,6 +1005,14 @@
         """Class for splitting an IO stream to two outputs."""
 
 
+    def flush(self):
+        """Flush all streams."""
+
+        # Call the streams' methods.
+        self.stream1.flush()
+        self.stream2.flush()
+
+
     def split(self, stream1, stream2):
         """Function for setting the streams."""
 




Related Messages


Powered by MHonArc, Updated Wed Feb 15 11:20:04 2012