Skip to content

Commit

Permalink
FIX Explicitly ignore SparseEfficiencyWarning in DBSCAN (#13539)
Browse files Browse the repository at this point in the history
  • Loading branch information
peay authored and TomDLT committed Apr 1, 2019
1 parent 26f6909 commit 6216b24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sklearn/cluster/dbscan_.py
Expand Up @@ -10,11 +10,11 @@
# License: BSD 3 clause

import numpy as np
import warnings
from scipy import sparse

from ..base import BaseEstimator, ClusterMixin
from ..utils import check_array, check_consistent_length
from ..utils.testing import ignore_warnings
from ..neighbors import NearestNeighbors

from ._dbscan_inner import dbscan_inner
Expand Down Expand Up @@ -145,7 +145,8 @@ def dbscan(X, eps=0.5, min_samples=5, metric='minkowski', metric_params=None,
X.sum_duplicates() # XXX: modifies X's internals in-place

# set the diagonal to explicit values, as a point is its own neighbor
with ignore_warnings():
with warnings.catch_warnings():
warnings.simplefilter('ignore', sparse.SparseEfficiencyWarning)
X.setdiag(X.diagonal()) # XXX: modifies X's internals in-place

X_mask = X.data <= eps
Expand Down

0 comments on commit 6216b24

Please sign in to comment.