Skip to content

Commit

Permalink
Corrected test of ambigious regex pattern using re.escape
Browse files Browse the repository at this point in the history
  • Loading branch information
kaichogami committed Feb 23, 2016
1 parent eeac91f commit 75d8d67
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sklearn/tests/test_multiclass.py
@@ -1,6 +1,8 @@
import numpy as np
import scipy.sparse as sp

from re import escape

from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_almost_equal
Expand Down Expand Up @@ -496,9 +498,10 @@ def test_ovo_partial_fit_predict():
#raises error when mini-batch does not have classes from all_classes
ovo = OneVsOneClassifier(MultinomialNB())
error_y = [0, 1, 2, 3, 4, 5, 2]
assert_raises_regexp(ValueError, "Mini-batch contains {0} while it must be "
"subset of {1}".format(np.unique(error_y), np.unique(y)),
ovo.partial_fit, X[:7], error_y, np.unique(y))
assert_raises_regexp(ValueError, escape("Mini-batch contains {0} while "
"it must be subset of {1}".format(np.unique(error_y),
np.unique(y))), ovo.partial_fit, X[:7], error_y,
np.unique(y))


def test_ovo_decision_function():
Expand Down

0 comments on commit 75d8d67

Please sign in to comment.