Author: bugman Date: Fri Oct 9 18:41:08 2009 New Revision: 9704 URL: http://svn.gna.org/viewcvs/relax?rev=9704&view=rev Log: Merged revisions 9696,9700 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r9696 | semor | 2009-10-09 14:44:40 +0200 (Fri, 09 Oct 2009) | 10 lines Improved the error handling for AICc model selection. The code now tells users with too small datasets (n<=k) why AICc model selection does not work in their situation. This follows a discussion started at: https://mail.gna.org/public/relax-devel/2009-10/msg00015.html (# Message-id: <4ACD6F60.7060102@xxxxxxxxx>) ........ r9700 | bugman | 2009-10-09 18:00:30 +0200 (Fri, 09 Oct 2009) | 3 lines Added a copyright notice and a function for returning the SVN revision number to the version module. ........ Modified: branches/bmrb/ (props changed) branches/bmrb/generic_fns/model_selection.py branches/bmrb/version.py Propchange: branches/bmrb/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Oct 9 18:41:08 2009 @@ -1,1 +1,1 @@ -/1.3:1-9658 +/1.3:1-9703 Modified: branches/bmrb/generic_fns/model_selection.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/model_selection.py?rev=9704&r1=9703&r2=9704&view=diff ============================================================================== --- branches/bmrb/generic_fns/model_selection.py (original) +++ branches/bmrb/generic_fns/model_selection.py Fri Oct 9 18:41:08 2009 @@ -73,7 +73,12 @@ @rtype: float """ - return chi2 + 2.0*k + 2.0*k*(k + 1.0) / (n - k - 1.0) + if n > (k+1): + return chi2 + 2.0*k + 2.0*k*(k + 1.0) / (n - k - 1.0) + elif n == (k+1): + raise RelaxError("The size of the dataset, n=%s, is too small for this model of size k=%s. This situation causes a fatal division by zero as:\n AICc = chi2 + 2k + 2k*(k + 1) / (n - k - 1).\n\nPlease use AIC model selection instead." % (n, k)) + elif n < (k+1): + raise RelaxError("The size of the dataset, n=%s, is too small for this model of size k=%s. This situation produces a negative, and hence nonsense, AICc score as:\n AICc = chi2 + 2k + 2k*(k + 1) / (n - k - 1).\n\nPlease use AIC model selection instead." % (n, k)) def bic(chi2, k, n): Modified: branches/bmrb/version.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/version.py?rev=9704&r1=9703&r2=9704&view=diff ============================================================================== --- branches/bmrb/version.py (original) +++ branches/bmrb/version.py Fri Oct 9 18:41:08 2009 @@ -1,1 +1,60 @@ +############################################################################### +# # +# 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 for relax version information.""" + +# Python module imports. +from os import F_OK, access +from string import split +from subprocess import PIPE, Popen + + version = "repository checkout" + + +def get_revision(): + """Attempt to retrieve the SVN revision number, if this is a checked out copy. + + @return: The SVN revision number, or None if unsuccessful. + @rtype: None or str + """ + + # Does the base directory exist (i.e. is this a checked out copy). + if not access('.svn', F_OK): + return + + # Try to run 'svn info'. + pipe = Popen('svn info', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + + # Errors. + if pipe.stderr.readlines(): + return + + # Loop over the output lines. + for line in pipe.stdout.readlines(): + # Split up the line. + row = split(line) + + # The revision. + if row[0] == 'Revision:': + return row[1]