Skip to content

Commit

Permalink
Remove FutureWarning about rcond by specifying it explictly (scikit-l…
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve authored and GaelVaroquaux committed Jul 17, 2018
1 parent bcd6ff3 commit 20b19f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/decomposition/plot_sparse_coding.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"""
print(__doc__)

from distutils.version import LooseVersion

import numpy as np
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -64,6 +66,8 @@ def ricker_matrix(width, resolution, n_components):
estimators = [('OMP', 'omp', None, 15, 'navy'),
('Lasso', 'lasso_cd', 2, None, 'turquoise'), ]
lw = 2
# Avoid FutureWarning about default value change when numpy >= 1.14
lstsq_rcond = None if LooseVersion(np.__version__) >= '1.14' else -1

plt.figure(figsize=(13, 6))
for subplot, (D, title) in enumerate(zip((D_fixed, D_multi),
Expand All @@ -88,7 +92,7 @@ def ricker_matrix(width, resolution, n_components):
transform_alpha=20)
x = coder.transform(y.reshape(1, -1))
_, idx = np.where(x != 0)
x[0, idx], _, _, _ = np.linalg.lstsq(D[idx, :].T, y)
x[0, idx], _, _, _ = np.linalg.lstsq(D[idx, :].T, y, rcond=lstsq_rcond)
x = np.ravel(np.dot(x, D))
squared_error = np.sum((y - x) ** 2)
plt.plot(x, color='darkorange', lw=lw,
Expand Down

0 comments on commit 20b19f8

Please sign in to comment.