Skip to content

Commit

Permalink
FIX Fixed array equality check in pprint (scikit-learn#13584)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored and TomDLT committed Apr 9, 2019
1 parent 0e3c187 commit d142764
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sklearn/utils/_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _changed_params(estimator):
init_params = signature(init_func).parameters
init_params = {name: param.default for name, param in init_params.items()}
for k, v in params.items():
if (v != init_params[k] and
if (repr(v) != repr(init_params[k]) and
not (is_scalar_nan(init_params[k]) and is_scalar_nan(v))):
filtered_params[k] = v
return filtered_params
Expand Down
4 changes: 4 additions & 0 deletions sklearn/utils/tests/test_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

from sklearn.utils._pprint import _EstimatorPrettyPrinter
from sklearn.linear_model import LogisticRegressionCV
from sklearn.pipeline import make_pipeline
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.feature_selection import SelectKBest, chi2
Expand Down Expand Up @@ -212,6 +213,9 @@ def test_changed_only():
expected = """SimpleImputer()"""
assert imputer.__repr__() == expected

# make sure array parameters don't throw error (see #13583)
repr(LogisticRegressionCV(Cs=np.array([0.1, 1])))

set_config(print_changed_only=False)


Expand Down

0 comments on commit d142764

Please sign in to comment.