From 6da31e4170f6dee9875b38f658e2f1887f29cf3b Mon Sep 17 00:00:00 2001 From: Brian Holt <bdholt1@gmail.com> Date: Wed, 31 Aug 2011 15:11:41 +0100 Subject: [PATCH] Standardise error messages --- scikits/learn/cross_val.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scikits/learn/cross_val.py b/scikits/learn/cross_val.py index 0a70c7eca8..24efcced59 100644 --- a/scikits/learn/cross_val.py +++ b/scikits/learn/cross_val.py @@ -198,9 +198,9 @@ class KFold(object): ----- All the folds have size trunc(n/k), the last one has the complementary """ - assert k > 0, ValueError('cannot have k below 1') - assert k <= n, ValueError('cannot have k=%d greater than the number ' - 'of samples: %d' % (k, n)) + assert k > 0, ValueError('Cannot have k below 1!') + assert k <= n, ValueError('Cannot have k=%d greater than the number ' + 'of samples: %d!' % (k, n)) self.n = n self.k = k self.indices = indices @@ -284,14 +284,14 @@ class StratifiedKFold(object): """ y = np.asanyarray(y) n = y.shape[0] - assert k > 0, ValueError('cannot have k below 1') - assert k <= n, ValueError('cannot have k=%d greater than the number ' - 'of samples %d' % (k, n)) + assert k > 0, ValueError('Cannot have k below 1!') + assert k <= n, ValueError('Cannot have k=%d greater than the number ' + 'of samples %d!' % (k, n)) _, y_sorted = unique(y, return_inverse=True) min_labels = np.min(np.bincount(y_sorted)) - assert k <= min_labels, ValueError('cannot have k=%d smaller than ' + assert k <= min_labels, ValueError('Cannot have k=%d smaller than ' 'the minimum number of labels ' - 'for any class %d' + 'for any class %d!' % (k, min_labels)) self.y = y self.k = k -- GitLab