mailr15371 - in /branches/relax_disp: ./ data/ generic_fns/ prompt/


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

Header


Content

Posted by edward on February 24, 2012 - 10:05:
Author: bugman
Date: Fri Feb 24 10:05:42 2012
New Revision: 15371

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

........
  r15322 | bugman | 2012-02-08 15:13:04 +0100 (Wed, 08 Feb 2012) | 3 lines
  
  The relax data store __repr__() method now prints out all objects within 
the base object.
........
  r15326 | bugman | 2012-02-08 15:33:34 +0100 (Wed, 08 Feb 2012) | 5 lines
  
  Implemented the rdc.delete and pcs.delete user function backends.
  
  This code previously did not exist, although the front ends were exposed to 
the user!
........
  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/relax_disp/   (props changed)
    branches/relax_disp/arg_check.py
    branches/relax_disp/data/__init__.py
    branches/relax_disp/generic_fns/pcs.py
    branches/relax_disp/generic_fns/rdc.py
    branches/relax_disp/prompt/pcs.py
    branches/relax_disp/prompt/rdc.py
    branches/relax_disp/relax_io.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Feb 24 10:05:42 2012
@@ -1,1 +1,1 @@
-/1.3:1-15261
+/1.3:1-15370

Modified: branches/relax_disp/arg_check.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/arg_check.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/arg_check.py (original)
+++ branches/relax_disp/arg_check.py Fri Feb 24 10:05:42 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/relax_disp/data/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/data/__init__.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/data/__init__.py (original)
+++ branches/relax_disp/data/__init__.py Fri Feb 24 10:05:42 2012
@@ -126,6 +126,28 @@
 
             # The text.
             text = text + "  %s %s: %s\n" % (name, type(obj), 
split(obj.__doc__, '\n')[0])
+
+        # All other objects.
+        text = text + "\n"
+        text = text + "All other objects:\n"
+        for name in dir(self):
+            # Skip special methods.
+            if search("^_", name):
+                continue
+
+            # Skip overwritten methods.
+            if name in list(self.__class__.__dict__.keys()):
+                continue
+
+            # Skip dictionary methods.
+            if name in dir(dict):
+                continue
+
+            # The object.
+            obj = getattr(self, name)
+
+            # The text.
+            text = text + "  %s %s: %s\n" % (name, type(obj), obj)
 
         # Return the text.
         return text

Modified: branches/relax_disp/generic_fns/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/generic_fns/pcs.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/generic_fns/pcs.py (original)
+++ branches/relax_disp/generic_fns/pcs.py Fri Feb 24 10:05:42 2012
@@ -24,6 +24,7 @@
 """Module for the manipulation of pseudocontact shift data."""
 
 # Python module imports.
+from copy import deepcopy
 from math import pi, sqrt
 from numpy import array, float64, ones, zeros
 from numpy.linalg import norm
@@ -313,6 +314,54 @@
 
         # The main data.
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)
+
+
+def delete(align_id=None):
+    """Delete the PCS data corresponding to the alignment ID.
+
+    @keyword align_id:  The alignment tensor ID string.  If not specified, 
all data will be deleted.
+    @type align_id:     str or None
+    """
+
+    # Test if the current data pipe exists.
+    pipes.test()
+
+    # Test if sequence data exists.
+    if not exists_mol_res_spin_data():
+        raise RelaxNoSequenceError
+
+    # Check that the ID exists.
+    if align_id and not align_id in cdp.pcs_ids:
+        raise RelaxError("The PCS alignment id '%s' does not exist" % 
align_id)
+
+    # The IDs.
+    if not align_id:
+        ids = deepcopy(cdp.pcs_ids)
+    else:
+        ids = [align_id]
+
+    # Loop over the alignments, removing all the corresponding data.
+    for id in ids:
+        # The PCS ID.
+        cdp.pcs_ids.pop(cdp.pcs_ids.index(id))
+
+        # The data type.
+        if hasattr(cdp, 'pcs_data_types') and cdp.pcs_data_types.has_key(id):
+            cdp.pcs_data_types.pop(id)
+
+        # The spin data.
+        for spin in spin_loop():
+            # The data.
+            if hasattr(spin, 'pcs') and spin.pcs.has_key(id):
+                spin.pcs.pop(id)
+
+            # The error.
+            if hasattr(spin, 'pcs_err') and spin.pcs_err.has_key(id):
+                spin.pcs_err.pop(id)
+
+        # Clean the global data.
+        if not hasattr(cdp, 'rdc_ids') or id not in cdp.rdc_ids:
+            cdp.align_ids.pop(id)
 
 
 def display(align_id=None, bc=False):

Modified: branches/relax_disp/generic_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/generic_fns/rdc.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/generic_fns/rdc.py (original)
+++ branches/relax_disp/generic_fns/rdc.py Fri Feb 24 10:05:42 2012
@@ -24,6 +24,7 @@
 """Module for the manipulation of RDC data."""
 
 # Python module imports.
+from copy import deepcopy
 from math import pi, sqrt
 from numpy import float64, ones, zeros
 from numpy.linalg import norm
@@ -240,6 +241,54 @@
 
         # The main data.
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)
+
+
+def delete(align_id=None):
+    """Delete the RDC data corresponding to the alignment ID.
+
+    @keyword align_id:  The alignment tensor ID string.  If not specified, 
all data will be deleted.
+    @type align_id:     str or None
+    """
+
+    # Test if the current data pipe exists.
+    pipes.test()
+
+    # Test if sequence data exists.
+    if not exists_mol_res_spin_data():
+        raise RelaxNoSequenceError
+
+    # Check that the ID exists.
+    if align_id and not align_id in cdp.rdc_ids:
+        raise RelaxError("The RDC alignment id '%s' does not exist" % 
align_id)
+
+    # The IDs.
+    if not align_id:
+        ids = deepcopy(cdp.rdc_ids)
+    else:
+        ids = [align_id]
+
+    # Loop over the alignments, removing all the corresponding data.
+    for id in ids:
+        # The RDC ID.
+        cdp.rdc_ids.pop(cdp.rdc_ids.index(id))
+
+        # The data type.
+        if hasattr(cdp, 'rdc_data_types') and cdp.rdc_data_types.has_key(id):
+            cdp.rdc_data_types.pop(id)
+
+        # The spin data.
+        for spin in spin_loop():
+            # The data.
+            if hasattr(spin, 'rdc') and spin.rdc.has_key(id):
+                spin.rdc.pop(id)
+
+            # The error.
+            if hasattr(spin, 'rdc_err') and spin.rdc_err.has_key(id):
+                spin.rdc_err.pop(id)
+
+        # Clean the global data.
+        if not hasattr(cdp, 'pcs_ids') or id not in cdp.pcs_ids:
+            cdp.align_ids.pop(id)
 
 
 def display(align_id=None, bc=False):

Modified: branches/relax_disp/prompt/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/prompt/pcs.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/prompt/pcs.py (original)
+++ branches/relax_disp/prompt/pcs.py Fri Feb 24 10:05:42 2012
@@ -231,7 +231,7 @@
             print(text)
 
         # The argument checks.
-        arg_check.is_str(align_id, 'alignment ID string')
+        arg_check.is_str(align_id, 'alignment ID string', can_be_none=True)
 
         # Execute the functional code.
         pcs.delete(align_id=align_id)

Modified: branches/relax_disp/prompt/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/prompt/rdc.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/prompt/rdc.py (original)
+++ branches/relax_disp/prompt/rdc.py Fri Feb 24 10:05:42 2012
@@ -231,7 +231,7 @@
             print(text)
 
         # The argument checks.
-        arg_check.is_str(align_id, 'alignment ID string')
+        arg_check.is_str(align_id, 'alignment ID string', can_be_none=True)
 
         # Execute the functional code.
         rdc.delete(align_id=align_id)

Modified: branches/relax_disp/relax_io.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/relax_io.py?rev=15371&r1=15370&r2=15371&view=diff
==============================================================================
--- branches/relax_disp/relax_io.py (original)
+++ branches/relax_disp/relax_io.py Fri Feb 24 10:05:42 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 Fri Feb 24 10:20:01 2012