mailr18112 - in /branches/relax_disp: ./ generic_fns/pipes.py test_suite/system_tests/pipes.py user_functions/pipe.py


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

Header


Content

Posted by edward on December 11, 2012 - 16:09:
Author: bugman
Date: Tue Dec 11 16:09:33 2012
New Revision: 18112

URL: http://svn.gna.org/viewcvs/relax?rev=18112&view=rev
Log:
Merged revisions 18108-18110 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r18108 | bugman | 2012-12-11 15:47:47 +0100 (Tue, 11 Dec 2012) | 5 lines
  
  Spun out code from generic_fns.pipes.create() into the new check_type() 
function.
  
  This code will be reused in a new pipe user function.
........
  r18109 | bugman | 2012-12-11 15:58:13 +0100 (Tue, 11 Dec 2012) | 3 lines
  
  Created the Pipes.test_change_type system test to check the non-existent 
pipe.change_type user function.
........
  r18110 | bugman | 2012-12-11 16:08:14 +0100 (Tue, 11 Dec 2012) | 3 lines
  
  Implemented the pipe.change_type user function front and back ends.
........

Modified:
    branches/relax_disp/   (props changed)
    branches/relax_disp/generic_fns/pipes.py
    branches/relax_disp/test_suite/system_tests/pipes.py
    branches/relax_disp/user_functions/pipe.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Dec 11 16:09:33 2012
@@ -1,1 +1,1 @@
-/trunk:1-18102
+/trunk:1-18110

Modified: branches/relax_disp/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/generic_fns/pipes.py?rev=18112&r1=18111&r2=18112&view=diff
==============================================================================
--- branches/relax_disp/generic_fns/pipes.py (original)
+++ branches/relax_disp/generic_fns/pipes.py Tue Dec 11 16:09:33 2012
@@ -93,6 +93,29 @@
     return list(ds.pipe_bundles.keys())
 
 
+def change_type(pipe_type=None):
+    """Change the type of the current data pipe.
+
+    @keyword pipe_type: The new data pipe type which can be one of the 
following:
+        'ct':  Consistency testing,
+        'frame order':  The Frame Order theories.
+        'jw':  Reduced spectral density mapping,
+        'hybrid':  The hybridised data pipe.
+        'mf':  Model-free analysis,
+        'N-state':  N-state model of domain dynamics,
+        'noe':  Steady state NOE calculation,
+        'relax_fit':  Relaxation curve fitting,
+        'relax_disp':  Relaxation dispersion,
+    @type pipe_type:    str
+    """
+
+    # Tests for the pipe type.
+    check_type(pipe_type)
+
+    # Change the type.
+    cdp.pipe_type = pipe_type
+
+
 def copy(pipe_from=None, pipe_to=None, bundle_to=None):
     """Copy the contents of the source data pipe to a new target data pipe.
 
@@ -162,17 +185,8 @@
     @type switch:       bool
     """
 
-    # Test if pipe_type is valid.
-    if not pipe_type in VALID_TYPES:
-        raise RelaxError("The data pipe type " + repr(pipe_type) + " is 
invalid and must be one of the strings in the list " + repr(VALID_TYPES) + 
".")
-
-    # Test that the C modules have been loaded.
-    if pipe_type == 'relax_fit' and not C_module_exp_fn:
-        raise RelaxError("Relaxation curve fitting is not available.  Try 
compiling the C modules on your platform.")
-
-    # Test that the scipy is installed for the frame order analysis.
-    if pipe_type == 'frame order' and not scipy_module:
-        raise RelaxError("The frame order analysis is not available.  Please 
install the scipy Python package.")
+    # Tests for the pipe type.
+    check_type(pipe_type)
 
     # Acquire the pipe lock (data modifying function), and make sure it is 
finally released.
     status.pipe_lock.acquire(sys._getframe().f_code.co_name)
@@ -183,6 +197,27 @@
     # Release the lock.
     finally:
         status.pipe_lock.release(sys._getframe().f_code.co_name)
+
+
+def check_type(pipe_type):
+    """Check the validity of the given data pipe type.
+
+    @keyword pipe_type: The data pipe type to check.
+    @type pipe_type:    str
+    @raises RelaxError: If the data pipe type is invalid or the required 
Python modules are missing.
+    """
+
+    # Test if pipe_type is valid.
+    if not pipe_type in VALID_TYPES:
+        raise RelaxError("The data pipe type " + repr(pipe_type) + " is 
invalid and must be one of the strings in the list " + repr(VALID_TYPES) + 
".")
+
+    # Test that the C modules have been loaded.
+    if pipe_type == 'relax_fit' and not C_module_exp_fn:
+        raise RelaxError("Relaxation curve fitting is not available.  Try 
compiling the C modules on your platform.")
+
+    # Test that the scipy is installed for the frame order analysis.
+    if pipe_type == 'frame order' and not scipy_module:
+        raise RelaxError("The frame order analysis is not available.  Please 
install the scipy Python package.")
 
 
 def cdp_name():

Modified: branches/relax_disp/test_suite/system_tests/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/test_suite/system_tests/pipes.py?rev=18112&r1=18111&r2=18112&view=diff
==============================================================================
--- branches/relax_disp/test_suite/system_tests/pipes.py (original)
+++ branches/relax_disp/test_suite/system_tests/pipes.py Tue Dec 11 16:09:33 
2012
@@ -32,6 +32,19 @@
 class Pipes(SystemTestCase):
     """TestCase class for the functional tests of relax data pipes."""
 
+    def test_change_type(self):
+        """Test the pipe.change_type user function."""
+
+        # Create the data pipe.
+        self.interpreter.pipe.create('test', 'frame order')
+
+        # Change the type.
+        self.interpreter.pipe.change_type('N-state')
+
+        # Check the type.
+        self.assertEqual(cdp.pipe_type, 'N-state')
+
+
     def test_pipe_bundle(self):
         """Test the pipe bundle concepts."""
 

Modified: branches/relax_disp/user_functions/pipe.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/pipe.py?rev=18112&r1=18111&r2=18112&view=diff
==============================================================================
--- branches/relax_disp/user_functions/pipe.py (original)
+++ branches/relax_disp/user_functions/pipe.py Tue Dec 11 16:09:33 2012
@@ -74,6 +74,35 @@
 uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_bundle.png'
 
         
+# The pipe.change_type user function.
+uf = uf_info.add_uf('pipe.change_type')
+uf.title = "Change the type of the current data pipe."
+uf.title_short = "Data pipe type change."
+uf.add_keyarg(
+    name = "pipe_type",
+    py_type = "str",
+    desc_short = "type of data pipe",
+    desc = "The type of data pipe.",
+    wiz_element_type = 'combo',
+    wiz_combo_choices = pipes.PIPE_DESC_LIST,
+    wiz_combo_data = pipes.VALID_TYPES,
+    wiz_read_only = True
+)
+uf.backend = pipes.change_type
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("The data pipe type must be one of the following:")
+for name in pipes.VALID_TYPES:
+    uf.desc[-1].add_item_list_element("'%s'" % name, "%s." % 
pipes.PIPE_DESC[name])
+# Prompt examples.
+uf.desc.append(Desc_container("Prompt examples"))
+uf.desc[-1].add_paragraph("To change the type of the current 'frame order' 
data pipe to the N-state model, type one of:")
+uf.desc[-1].add_prompt("relax> pipe.change_type('N-state')")
+uf.desc[-1].add_prompt("relax> pipe.change_type(pipe_type='N-state')")
+uf.menu_text = "change_&type"
+uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png'
+
+
 # The pipe.copy user function.
 uf = uf_info.add_uf('pipe.copy')
 uf.title = "Copy a data pipe."




Related Messages


Powered by MHonArc, Updated Tue Dec 11 16:20:01 2012