Skip to content

Commit

Permalink
MAINT Fix invalid escape sequence (scikit-learn#12064)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinjalali authored and qinhanmin2014 committed Sep 13, 2018
1 parent dad5c36 commit 36536c6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sklearn/cluster/tests/test_k_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def test_sparse_validate_centers():
# Test that a ValueError is raised for validate_center_shape
classifier = KMeans(n_clusters=3, init=centers, n_init=1)

msg = "The shape of the initial centers \(\(4L?, 4L?\)\) " \
msg = r"The shape of the initial centers \(\(4L?, 4L?\)\) " \
"does not match the number of clusters 3"
assert_raises_regex(ValueError, msg, classifier.fit, X)

Expand Down Expand Up @@ -969,7 +969,7 @@ def test_sample_weight_length():
# check that an error is raised when passing sample weights
# with an incompatible shape
km = KMeans(n_clusters=n_clusters, random_state=42)
assert_raises_regex(ValueError, 'len\(sample_weight\)', km.fit, X,
assert_raises_regex(ValueError, r'len\(sample_weight\)', km.fit, X,
sample_weight=np.ones(2))


Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/mlcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _load_document_classification(dataset_path, metadata, set_=None, **kwargs):
"in March 2017, the load_mlcomp function was deprecated "
"in version 0.19 and will be removed in 0.21.")
def load_mlcomp(name_or_id, set_="raw", mlcomp_root=None, **kwargs):
"""Load a datasets as downloaded from http://mlcomp.org
r"""Load a datasets as downloaded from http://mlcomp.org
Read more in the :ref:`User Guide <datasets>`.
Expand Down
2 changes: 1 addition & 1 deletion sklearn/externals/_arff.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def _decode_comment(self, s):
:param s: a normalized string.
:return: a string with the decoded comment.
'''
res = re.sub('^\%( )?', '', s)
res = re.sub(r'^\%( )?', '', s)
return res

def _decode_relation(self, s):
Expand Down
6 changes: 3 additions & 3 deletions sklearn/model_selection/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def assert_grid_iter_equals_getitem(grid):

@pytest.mark.parametrize(
"input, error_type, error_message",
[(0, TypeError, 'Parameter grid is not a dict or a list \(0\)'),
([{'foo': [0]}, 0], TypeError, 'Parameter grid is not a dict \(0\)'),
[(0, TypeError, r'Parameter grid is not a dict or a list \(0\)'),
([{'foo': [0]}, 0], TypeError, r'Parameter grid is not a dict \(0\)'),
({'foo': 0}, TypeError, "Parameter grid value is not iterable "
"\(key='foo', value=0\)")]
r"\(key='foo', value=0\)")]
)
def test_validate_parameter_grid_input(input, error_type, error_message):
with pytest.raises(error_type, match=error_message):
Expand Down

0 comments on commit 36536c6

Please sign in to comment.