Skip to content

Commit

Permalink
MAINT Fix scipy-dev-wheels build (#11251)
Browse files Browse the repository at this point in the history
Ignore PendingDeprecationWarning
  • Loading branch information
lesteve authored and jnothman committed Jun 24, 2018
1 parent 97a15db commit 60f887e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions sklearn/ensemble/tests/test_iforest.py
Expand Up @@ -6,6 +6,8 @@
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# License: BSD 3 clause

import pytest

import numpy as np

from sklearn.utils.fixes import euler_gamma
Expand All @@ -15,7 +17,6 @@
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_warns_message
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_no_warnings
from sklearn.utils.testing import assert_greater
from sklearn.utils.testing import ignore_warnings

Expand Down Expand Up @@ -105,8 +106,20 @@ def test_iforest_error():
assert_warns_message(UserWarning,
"max_samples will be set to n_samples for estimation",
IsolationForest(max_samples=1000).fit, X)
assert_no_warnings(IsolationForest(max_samples='auto').fit, X)
assert_no_warnings(IsolationForest(max_samples=np.int64(2)).fit, X)
# note that assert_no_warnings does not apply since it enables a
# PendingDeprecationWarning triggered by scipy.sparse's use of
# np.matrix. See issue #11251.
with pytest.warns(None) as record:
IsolationForest(max_samples='auto').fit(X)
user_warnings = [each for each in record
if issubclass(each.category, UserWarning)]
assert len(user_warnings) == 0
with pytest.warns(None) as record:
IsolationForest(max_samples=np.int64(2)).fit(X)
user_warnings = [each for each in record
if issubclass(each.category, UserWarning)]
assert len(user_warnings) == 0

assert_raises(ValueError, IsolationForest(max_samples='foobar').fit, X)
assert_raises(ValueError, IsolationForest(max_samples=1.5).fit, X)

Expand Down

0 comments on commit 60f887e

Please sign in to comment.