From 8876d349a84ed76715ea52beeeec1348a485fb53 Mon Sep 17 00:00:00 2001
From: Mathieu Blondel <mathieu@mblondel.org>
Date: Mon, 21 Feb 2011 19:09:35 +0900
Subject: [PATCH] Add tests for sanity checks in SVC.

---
 scikits/learn/svm/tests/test_svm.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scikits/learn/svm/tests/test_svm.py b/scikits/learn/svm/tests/test_svm.py
index 0ffd085d54..46e0e3be0c 100644
--- a/scikits/learn/svm/tests/test_svm.py
+++ b/scikits/learn/svm/tests/test_svm.py
@@ -123,6 +123,20 @@ def test_precomputed():
     clf.fit(iris.data, iris.target)
     assert_almost_equal(np.mean(pred == iris.target), .99, decimal=2)
 
+def test_sanity_checks_fit():
+    clf = svm.SVC(kernel='precomputed')
+    assert_raises(ValueError, clf.fit, X, Y)
+
+def test_sanity_checks_predict():
+    Xt = np.array(X).T
+
+    clf = svm.SVC(kernel='precomputed')
+    clf.fit(np.dot(X, Xt), Y)
+    assert_raises(ValueError, clf.predict, X)
+
+    clf = svm.SVC()
+    clf.fit(X, Y)
+    assert_raises(ValueError, clf.predict, Xt)
 
 def test_SVR():
     """
-- 
GitLab