mailr26074 - in /branches/frame_order_cleanup: ./ lib/ pipe_control/ specific_analyses/model_free/ test_suite/system_tests/


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

Header


Content

Posted by edward on September 26, 2014 - 19:09:
Author: bugman
Date: Fri Sep 26 19:09:29 2014
New Revision: 26074

URL: http://svn.gna.org/viewcvs/relax?rev=26074&view=rev
Log:
Merged revisions 26044-26046,26048-26056 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r26044 | bugman | 2014-09-26 09:52:37 +0200 (Fri, 26 Sep 2014) | 7 lines
  
  Created the pipe_control.spectrometer.check_setup() function.
  
  This follows the design on the wiki page 
http://wiki.nmr-relax.com/Relax_source_design.
  
  This is for checking if spectrometer information has been set up.
........
  r26045 | bugman | 2014-09-26 09:55:10 +0200 (Fri, 26 Sep 2014) | 3 lines
  
  Created the RelaxNoFrqWarning warning class for warning that no 
spectrometer information is present.
........
  r26046 | bugman | 2014-09-26 10:00:58 +0200 (Fri, 26 Sep 2014) | 5 lines
  
  Renamed the pipe_control.spectrometer.check_setup() function to 
check_spectrometer_setup().
  
  This is so it can be used without confusion outside of the module.
........
  r26048 | bugman | 2014-09-26 10:05:42 +0200 (Fri, 26 Sep 2014) | 3 lines
  
  Fix for a broken elif block in the new 
pipe_control.spectrometer.check_spectrometer_setup() function.
........
  r26049 | bugman | 2014-09-26 10:06:58 +0200 (Fri, 26 Sep 2014) | 5 lines
  
  The model-free bmrb_write() API method now checks for spectrometer 
information.
  
  This is via a call to the 
pipe_control.spectrometer.check_spectrometer_setup() function.
........
  r26050 | bugman | 2014-09-26 10:09:18 +0200 (Fri, 26 Sep 2014) | 3 lines
  
  Modified the Bmrb.test_bug_22703_display_empty system/GUI test to catch the 
RelaxNoFrqError.
........
  r26051 | bugman | 2014-09-26 11:31:29 +0200 (Fri, 26 Sep 2014) | 6 lines
  
  Created a special Check class based on the strategy design pattern.
  
  This is in the new lib.checks module.  The class will be used to simplify 
and unify all of the
  check_*() functions in the pipe_control and specific_analyses packages.
........
  r26052 | bugman | 2014-09-26 11:43:15 +0200 (Fri, 26 Sep 2014) | 6 lines
  
  Converted the pipe_control.spectrometer.check_*() functions to the strategy 
design pattern.
  
  These are now passed into the lib.checks.Check object, and the original 
functions are now instances
  of this class.
........
  r26053 | bugman | 2014-09-26 11:44:00 +0200 (Fri, 26 Sep 2014) | 5 lines
  
  Updated the Bmrb.test_bug_22703_display_empty system/GUI test.
  
  The RelaxError type is now different.
........
  r26054 | bugman | 2014-09-26 12:15:23 +0200 (Fri, 26 Sep 2014) | 3 lines
  
  Alphabetical ordering of all functions in the pipe_control.pipes module.
........
  r26055 | bugman | 2014-09-26 12:40:16 +0200 (Fri, 26 Sep 2014) | 9 lines
  
  Changed the design of the Check object in lib.checks.
  
  The design of the checking function to call has been modified - it should 
now return either None if
  the check passes or an instantiated RelaxError object if not.  This is then 
used to determine if the
  __call__() method should return True (when None is received).  Otherwise if 
escalate is set to 1,
  the text from the RelaxError object is sent into a RelaxWarning and False 
is returned.  And if
  escalate is set to 2, then the error object is simply raised.
........
  r26056 | bugman | 2014-09-26 12:41:06 +0200 (Fri, 26 Sep 2014) | 3 lines
  
  Updated the pipe_control.spectrometer.check_*_func() functions to use the 
new design.
........

Added:
    branches/frame_order_cleanup/lib/checks.py
      - copied unchanged from r26056, trunk/lib/checks.py
Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/lib/__init__.py
    branches/frame_order_cleanup/lib/warnings.py
    branches/frame_order_cleanup/pipe_control/pipes.py
    branches/frame_order_cleanup/pipe_control/spectrometer.py
    branches/frame_order_cleanup/specific_analyses/model_free/api.py
    branches/frame_order_cleanup/test_suite/system_tests/bmrb.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Sep 26 19:09:29 2014
@@ -1 +1 @@
-/trunk:1-26017,26043
+/trunk:1-26017,26043-26056

Modified: branches/frame_order_cleanup/lib/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/__init__.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/__init__.py        (original)
+++ branches/frame_order_cleanup/lib/__init__.py        Fri Sep 26 19:09:29 
2014
@@ -29,6 +29,7 @@
     'arg_check',
     'auto_relaxation',
     'check_types',
+    'checks',
     'chemical_shift',
     'compat',
     'curve_fit',

Modified: branches/frame_order_cleanup/lib/warnings.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/warnings.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/warnings.py        (original)
+++ branches/frame_order_cleanup/lib/warnings.py        Fri Sep 26 19:09:29 
2014
@@ -188,3 +188,18 @@
 class RelaxDeselectWarning(BaseWarning):
     def __init__(self, spin_id, reason):
         self.text = "The spin '%s' has been deselected because of %s." % 
(spin_id, reason)
+
+
+# Spectrometer information warnings.
+####################################
+
+# No frequency information.
+class RelaxNoFrqWarning(BaseWarning):
+    def __init__(self, pipe_name=None, id=None):
+        self.text = "No spectrometer frequency information"
+        if id != None:
+            self.text += " for the '%s' experiment ID" % id
+        self.text += " is present"
+        if pipe_name != None:
+            self.text += " in the '%s' data pipe" % pipe_name
+        self.text += "."

Modified: branches/frame_order_cleanup/pipe_control/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/pipes.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/pipe_control/pipes.py  (original)
+++ branches/frame_order_cleanup/pipe_control/pipes.py  Fri Sep 26 19:09:29 
2014
@@ -91,6 +91,16 @@
     return list(ds.pipe_bundles.keys())
 
 
+def cdp_name():
+    """Return the name of the current data pipe.
+    
+    @return:        The name of the current data pipe.
+    @rtype:         str
+    """
+
+    return ds.current_pipe
+
+
 def change_type(pipe_type=None):
     """Change the type of the current data pipe.
 
@@ -112,6 +122,27 @@
 
     # Change the type.
     cdp.pipe_type = pipe_type
+
+
+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 copy(pipe_from=None, pipe_to=None, bundle_to=None):
@@ -197,37 +228,6 @@
         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():
-    """Return the name of the current data pipe.
-    
-    @return:        The name of the current data pipe.
-    @rtype:         str
-    """
-
-    return ds.current_pipe
-
-
 def current():
     """Print the name of the current data pipe."""
 

Modified: branches/frame_order_cleanup/pipe_control/spectrometer.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/spectrometer.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/pipe_control/spectrometer.py   (original)
+++ branches/frame_order_cleanup/pipe_control/spectrometer.py   Fri Sep 26 
19:09:29 2014
@@ -27,22 +27,47 @@
 from warnings import warn
 
 # relax module imports.
+from lib.checks import Check
 from lib.errors import RelaxError, RelaxNoFrqError
 from lib.periodic_table import periodic_table
-from lib.warnings import RelaxWarning
+from lib.warnings import RelaxWarning, RelaxNoFrqWarning
 from pipe_control import pipes
 
 
-def check_frequency(id=None):
+def check_frequency_func(self, id=None):
     """Check that the frequency for the given ID has been set.
 
-    @param id:          The experiment ID string.
-    @type id:           str
+    @keyword id:    The experiment ID string.
+    @type id:       str
+    @return:        The initialised RelaxError object or nothing.
+    @rtype:         None or RelaxError instance
     """
 
     # Check for the ID.
-    if not hasattr(cdp, 'spectrometer_frq') or id not in 
cdp.spectrometer_frq.keys():
-        raise RelaxNoFrqError(id=id)
+    if not hasattr(cdp, 'spectrometer_frq') and id not in 
cdp.spectrometer_frq.keys():
+        return RelaxNoFrqError(id=id)
+
+# Create the checking object.
+check_frequency = Check(check_frequency_func)
+
+
+def check_spectrometer_setup_func(self):
+    """Check that spectrometer frequencies have been set up.
+
+    @return:    The initialised RelaxError object or nothing.
+    @rtype:     None or RelaxError instance
+    """
+
+    # No data structure.
+    if not hasattr(cdp, 'spectrometer_frq'):
+        return RelaxNoFrqError()
+
+    # An empty list.
+    if not len(cdp.spectrometer_frq):
+        return RelaxNoFrqError()
+
+# Create the checking object.
+check_spectrometer_setup = Check(check_spectrometer_setup_func)
 
 
 def copy_frequencies(pipe_from=None, pipe_to=None, id=None):

Modified: branches/frame_order_cleanup/specific_analyses/model_free/api.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/model_free/api.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/model_free/api.py    
(original)
+++ branches/frame_order_cleanup/specific_analyses/model_free/api.py    Fri 
Sep 26 19:09:29 2014
@@ -51,6 +51,7 @@
 from pipe_control.exp_info import bmrb_write_citations, bmrb_write_methods, 
bmrb_write_software
 from pipe_control.interatomic import return_interatom_list
 from pipe_control.mol_res_spin import count_spins, exists_mol_res_spin_data, 
find_index, get_molecule_names, return_spin, return_spin_from_index, 
return_spin_indices, spin_loop
+from pipe_control.spectrometer import check_spectrometer_setup
 from specific_analyses.api_base import API_base
 from specific_analyses.api_common import API_common
 from specific_analyses.model_free.bmrb import sf_csa_read, 
sf_model_free_read, to_bmrb_model
@@ -180,6 +181,9 @@
         @keyword version:   The BMRB NMR-STAR dictionary format to output to.
         @type version:      str
         """
+
+        # Checks.
+        check_spectrometer_setup(escalate=2)
 
         # Alias the current data pipe.
         cdp = pipes.get_pipe()

Modified: branches/frame_order_cleanup/test_suite/system_tests/bmrb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/bmrb.py?rev=26074&r1=26073&r2=26074&view=diff
==============================================================================
--- branches/frame_order_cleanup/test_suite/system_tests/bmrb.py        
(original)
+++ branches/frame_order_cleanup/test_suite/system_tests/bmrb.py        Fri 
Sep 26 19:09:29 2014
@@ -260,14 +260,14 @@
         self.interpreter.pipe.create('test', 'mf')
 
         # Display.
-        self.interpreter.bmrb.display(version='3.1')
+        self.assertRaises(RelaxError, self.interpreter.bmrb.display, 
version='3.1')
 
         # Reset and create a new data pipe.
         self.interpreter.reset()
         self.interpreter.pipe.create('test2', 'mf')
 
         # Display again to show a GUI breakage.
-        self.interpreter.bmrb.display(version='3.1')
+        self.assertRaises(RelaxError, self.interpreter.bmrb.display, 
version='3.1')
 
 
     def test_rw_bmrb_3_0_model_free(self):




Related Messages


Powered by MHonArc, Updated Fri Sep 26 19:20:03 2014