8000 MNT Catches scipy 1.3.0 for using deprecated tostring method by thomasjpfan · Pull Request #18755 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MNT Catches scipy 1.3.0 for using deprecated tostring method #18755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions sklearn/ensemble/tests/test_voting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Testing for the VotingClassifier and VotingRegressor"""

import warnings
import pytest
import re
import numpy as np
Expand Down Expand Up @@ -370,7 +371,11 @@ def test_set_estimator_drop():
('nb', clf3)],
voting='hard', weights=[1, 1, 0.5])
with pytest.warns(None) as record:
eclf2.set_params(rf='drop').fit(X, y)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
eclf2.set_params(rf='drop').fit(X, y)

assert not record
assert_array_equal(eclf1.predict(X), eclf2.predict(X))

Expand All @@ -382,7 +387,11 @@ def test_set_estimator_drop():

eclf1.set_params(voting='soft').fit(X, y)
with pytest.warns(None) as record:
eclf2.set_params(voting='soft').fit(X, y)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
eclf2.set_params(voting='soft').fit(X, y)

assert not record
assert_array_equal(eclf1.predict(X), eclf2.predict(X))
assert_array_almost_equal(eclf1.predict_proba(X), eclf2.predict_proba(X))
Expand All @@ -403,7 +412,10 @@ def test_set_estimator_drop():
voting='soft', weights=[1, 0.5],
flatten_transform=False)
with pytest.warns(None) as record:
eclf2.set_params(rf='drop').fit(X1, y1)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
eclf2.set_params(rf='drop').fit(X1, y1)
assert not record
assert_array_almost_equal(eclf1.transform(X1),
np.array([[[0.7, 0.3], [0.3, 0.7]],
Expand Down
11 changes: 9 additions & 2 deletions sklearn/gaussian_process/tests/test_gpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Author: Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
# License: BSD 3 clause

import warnings
import numpy as np

from scipy.optimize import approx_fprime
Expand Down Expand Up @@ -201,7 +202,10 @@ def test_warning_bounds():
RBF(length_scale_bounds=[1e3, 1e5]))
gpc_sum = GaussianProcessClassifier(kernel=kernel_sum)
with pytest.warns(None) as record:
gpc_sum.fit(X, y)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
gpc_sum.fit(X, y)

assert len(record) == 2
assert record[0].message.args[0] == ("The optimal value found for "
Expand All @@ -224,7 +228,10 @@ def test_warning_bounds():
gpc_dims = GaussianProcessClassifier(kernel=kernel_dims)

with pytest.warns(None) as record:
gpc_dims.fit(X_tile, y)
with warnings.catch_warnings():
8000 # scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
gpc_dims.fit(X_tile, y)

assert len(record) == 2
assert record[0].message.args[0] == ("The optimal value found for "
Expand Down
11 changes: 9 additions & 2 deletions sklearn/gaussian_process/tests/test_gpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import sys
import numpy as np
import warnings

from scipy.optimize import approx_fprime

Expand Down Expand Up @@ -486,7 +487,10 @@ def test_warning_bounds():
RBF(length_scale_bounds=[1e3, 1e5]))
gpr_sum = GaussianProcessRegressor(kernel=kernel_sum)
with pytest.warns(None) as record:
gpr_sum.fit(X, y)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
gpr_sum.fit(X, y)

assert len(record) == 2
assert record[0].message.args[0] == ("The optimal value found for "
Expand All @@ -509,7 +513,10 @@ def test_warning_bounds():
gpr_dims = GaussianProcessRegressor(kernel=kernel_dims)

with pytest.warns(None) as record:
gpr_dims.fit(X_tile, y)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
gpr_dims.fit(X_tile, y)

assert len(record) == 2
assert record[0].message.args[0] == ("The optimal value found for "
Expand Down
8 changes: 6 additions & 2 deletions sklearn/linear_model/tests/test_logistic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import warnings
import numpy as np
from numpy.testing import assert_allclose, assert_almost_equal
from numpy.testing import assert_array_almost_equal, assert_array_equal
Expand Down Expand Up @@ -391,8 +392,11 @@ def test_logistic_regression_path_convergence_fail():
# advice (scaling the data) and to the logistic regression specific
# documentation that includes hints on the solver configuration.
with pytest.warns(ConvergenceWarning) as record:
_logistic_regression_path(
X, y, Cs=Cs, tol=0., max_iter=1, random_state=0, verbose=0)
with warnings.catch_warnings():
# scipy 1.3.0 uses tostring which is deprecated in numpy
warnings.filterwarnings("ignore", "tostring", DeprecationWarning)
_logistic_regression_path(
X, y, Cs=Cs, tol=0., max_iter=1, random_state=0, verbose=0)

assert len(record) == 1
warn_msg = record[0].message.args[0]
Expand Down
0