Author: bugman Date: Sat Nov 29 18:55:20 2014 New Revision: 26851 URL: http://svn.gna.org/viewcvs/relax?rev=26851&view=rev Log: Created the new specific_analyses.relax_fit.checks module.
This creates the check_model_setup Check object, following the check_*() function design at http://wiki.nmr-relax.com/Relax_source_design#The_check_.2A.28.29_functions. This will be used to make sure that the exponential curve model is set prior to executing certain user functions. Added: trunk/specific_analyses/relax_fit/checks.py Added: trunk/specific_analyses/relax_fit/checks.py URL: http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_fit/checks.py?rev=26851&view=auto ============================================================================== --- trunk/specific_analyses/relax_fit/checks.py (added) +++ trunk/specific_analyses/relax_fit/checks.py Sat Nov 29 18:55:20 2014 @@ -0,0 +1,49 @@ +############################################################################### +# # +# Copyright (C) 2014 Edward d'Auvergne # +# # +# This file is part of the program relax (http://www.nmr-relax.com). # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +# # +############################################################################### + +# Module docstring. +"""Module of functions for checking different aspects of the relaxation curve-fitting setup.""" + +# relax module imports. +from lib.checks import Check +from lib.errors import RelaxError +from pipe_control.mol_res_spin import spin_loop + + +def check_model_setup_func(): + """Check that the model has been correctly set up. + + @return: The initialised RelaxError object or nothing. + @rtype: None or RelaxError instance + """ + + # Test if the model has been set. + for spin in spin_loop(): + # Skip deselected spins. + if not spin.select: + continue + + # No model set. + if not hasattr(spin, 'model'): + return RelaxError("The exponential curve model has not been set, please use the relax_fit.select_model user function.") + +# Create the checking object. +check_model_setup = Check(check_model_setup_func) _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits