Author: bugman Date: Mon Jul 13 00:03:51 2009 New Revision: 9195 URL: http://svn.gna.org/viewcvs/relax?rev=9195&view=rev Log: Created lists of number types (python and numpy). These are in the prompt.num_types module and are now used by value.set() for argument checking. Added: 1.3/prompt/num_types.py Modified: 1.3/prompt/value.py Added: 1.3/prompt/num_types.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/num_types.py?rev=9195&view=auto ============================================================================== --- 1.3/prompt/num_types.py (added) +++ 1.3/prompt/num_types.py Mon Jul 13 00:03:51 2009 @@ -1,0 +1,32 @@ +############################################################################### +# # +# Copyright (C) 2009 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax 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 2 of the License, or # +# (at your option) any later version. # +# # +# relax 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 relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""Module containing number type lists for argument checks.""" + +# Python module imports. +from numpy import int8, int16, int32, int64, float32, float64, float128 + + +# The lists. +int_list = [int, int8, int16, int32] +float_list = [float, float32, float64, float128] Modified: 1.3/prompt/value.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/value.py?rev=9195&r1=9194&r2=9195&view=diff ============================================================================== --- 1.3/prompt/value.py (original) +++ 1.3/prompt/value.py Mon Jul 13 00:03:51 2009 @@ -32,6 +32,7 @@ import help from generic_fns import diffusion_tensor from generic_fns import value +from num_types import int_list, float_list from relax_errors import RelaxError, RelaxFloatError, RelaxIntError, RelaxListFloatStrError, RelaxListStrError, RelaxNoneFloatStrListError, RelaxNoneIntError, RelaxNoneStrError, RelaxNoneStrListError, RelaxStrError from specific_fns.model_free import Model_free from specific_fns.jw_mapping import Jw_mapping @@ -209,7 +210,7 @@ raise RelaxStrError, ('parameter', param) # The scaling factor. - if type(scaling) != float: + if type(scaling) not in float_list: raise RelaxFloatError, ('scaling', scaling) # The file name. @@ -217,19 +218,19 @@ raise RelaxStrError, ('file', file) # The number column. - if type(num_col) != int: + if type(num_col) not in int_list: raise RelaxIntError, ('residue number column', num_col) # The name column. - if name_col != None and type(name_col) != int: + if name_col != None and type(name_col) not in int_list: raise RelaxNoneIntError, ('residue name column', name_col) # The data column. - if type(data_col) != int: + if type(data_col) not in int_list: raise RelaxIntError, ('data column', data_col) # The error column. - if error_col != None and type(error_col) != int: + if error_col != None and type(error_col) not in int_list: raise RelaxNoneIntError, ('error column', error_col) # Column separator. @@ -368,7 +369,7 @@ print text # The value. - if val != None and type(val) != float and type(val) != int and type(val) != str and type(val) != list: + if val != None and type(val) not in float_list and type(val) not in int_list and type(val) != str and type(val) != list: raise RelaxNoneFloatStrListError, ('value', val) if type(val) == list: # Empty list. @@ -377,7 +378,8 @@ # Check for values. for i in xrange(len(val)): - if type(val[i]) != float and type(val[i]) != int: + if type(val[i]) not in float_list and type(val[i]) not in int_list: + print type(val[i]) raise RelaxListFloatStrError, ('value', val) # The parameter.