Author: bugman Date: Fri Jan 11 10:38:41 2008 New Revision: 4626 URL: http://svn.gna.org/viewcvs/relax?rev=4626&view=rev Log: Implemented the tensors arg to the align_tensor svd() and matrix_angles() user functions. The new error RelaxNoneListstrError has also been created. Modified: branches/N_state_model/prompt/align_tensor.py branches/N_state_model/relax_errors.py Modified: branches/N_state_model/prompt/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/N_state_model/prompt/align_tensor.py?rev=4626&r1=4625&r2=4626&view=diff ============================================================================== --- branches/N_state_model/prompt/align_tensor.py (original) +++ branches/N_state_model/prompt/align_tensor.py Fri Jan 11 10:38:41 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2007 Edward d'Auvergne # +# Copyright (C) 2007-2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -26,7 +26,7 @@ # relax module imports. import help from generic_fns import align_tensor -from relax_errors import RelaxError, RelaxBinError, RelaxFloatError, RelaxIntError, RelaxNoneStrError, RelaxNumTupleError, RelaxStrError +from relax_errors import RelaxError, RelaxBinError, RelaxFloatError, RelaxIntError, RelaxNoneListstrError, RelaxNoneStrError, RelaxNumTupleError, RelaxStrError class Align_tensor: @@ -285,13 +285,15 @@ align_tensor.init(tensor=tensor, params=params, scale=scale, angle_units=angle_units, param_types=param_types, errors=errors) - def matrix_angles(self, basis_set=0): + def matrix_angles(self, basis_set=0, tensors=None): """Function for calculating the 5D angles between all alignment tensors. Keyword Arguments ~~~~~~~~~~~~~~~~~ basis_set: The basis set to operate with. + + tensors: A list of the tensors to apply the calculation to. If None, all tensors are used. Description @@ -307,24 +309,40 @@ # Function intro text. if self.__relax__.interpreter.intro: text = sys.ps3 + "align_tensor.matrix_angles(" - text = text + "basis_set=" + `basis_set` + ")" + text = text + "basis_set=" + `basis_set` + text = text + ", tensors=" + `tensors` + ")" print text # Basis set argument. if type(basis_set) != int: raise RelaxIntError, ('basis set', basis_set) - # Execute the functional code. - align_tensor.matrix_angles(basis_set) - - - def svd(self, basis_set=0): + # Tensors argument. + if tensors != None or type(tensors) != list: + raise RelaxNoneListstrError, ('tensors', tensors) + if type(tensors) == list: + # Empty list. + if tensors == []: + raise RelaxNoneListstrError, ('tensors', tensors) + + # Check for strings. + for i in xrange(len(tensors)): + if type(tensors[i]) != str: + raise RelaxNoneListstrError, ('tensors', tensors) + + # Execute the functional code. + align_tensor.matrix_angles(basis_set, tensors) + + + def svd(self, basis_set=0, tensors=None): """Function for calculating the singular values for all tensors and the condition number. Keyword Arguments ~~~~~~~~~~~~~~~~~ basis_set: The basis set to operate with. + + tensors: A list of the tensors to apply the calculation to. If None, all tensors are used. Description @@ -366,12 +384,26 @@ # Function intro text. if self.__relax__.interpreter.intro: text = sys.ps3 + "align_tensor.svd(" - text = text + "basis_set=" + `basis_set` + ")" + text = text + "basis_set=" + `basis_set` + text = text + ", tensors=" + `tensors` + ")" print text # Basis set argument. if type(basis_set) != int: raise RelaxIntError, ('basis set', basis_set) - # Execute the functional code. - align_tensor.svd(basis_set) + # Tensors argument. + if tensors != None or type(tensors) != list: + raise RelaxNoneListstrError, ('tensors', tensors) + if type(tensors) == list: + # Empty list. + if tensors == []: + raise RelaxNoneListstrError, ('tensors', tensors) + + # Check for strings. + for i in xrange(len(tensors)): + if type(tensors[i]) != str: + raise RelaxNoneListstrError, ('tensors', tensors) + + # Execute the functional code. + align_tensor.svd(basis_set, tensors) Modified: branches/N_state_model/relax_errors.py URL: http://svn.gna.org/viewcvs/relax/branches/N_state_model/relax_errors.py?rev=4626&r1=4625&r2=4626&view=diff ============================================================================== --- branches/N_state_model/relax_errors.py (original) +++ branches/N_state_model/relax_errors.py Fri Jan 11 10:38:41 2008 @@ -369,6 +369,13 @@ if Debug: self.save_state() +# None or list of strings. +class RelaxNoneListstrError(BaseError): + def __init__(self, name, value): + self.text = "The " + name + " argument " + `value` + " must either be an array of strings or None." + if Debug: + self.save_state() + # None or number. class RelaxNoneNumError(BaseError): def __init__(self, name, value):