Skip to content

Commit c49c580

Browse files
author
Guillaume Lemaitre
committed
try to force the raising
1 parent fd5d977 commit c49c580

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

imblearn/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
from sklearn.utils import check_X_y
1515
from sklearn.utils.multiclass import type_of_target
1616

17-
logging.captureWarnings(False)
18-
warnings.simplefilter('always', UserWarning)
19-
2017

2118
class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)):
2219

@@ -87,6 +84,7 @@ def fit(self, X, y):
8784
self.logger.debug('Shall we raise a warning: %s',
8885
np.unique(y).size == 1)
8986
if np.unique(y).size == 1:
87+
warnings.simplefilter('always', UserWarning)
9088
warnings.warn('Only one class detected, something will get wrong')
9189
self.logger.debug('The warning should has been raised.')
9290

@@ -257,6 +255,7 @@ def fit(self, X, y):
257255

258256
# Check that the target type is binary
259257
if not type_of_target(y) == 'binary':
258+
warnings.simplefilter('always', UserWarning)
260259
warnings.warn('The target type should be binary.')
261260

262261
return self
@@ -293,6 +292,7 @@ def fit(self, X, y):
293292
# Check that the target type is either binary or multiclass
294293
if not (type_of_target(y) == 'binary' or
295294
type_of_target(y) == 'multiclass'):
295+
warnings.simplefilter('always', UserWarning)
296296
warnings.warn('The target type should be binary or multiclass.')
297297

298298
return self

0 commit comments

Comments
 (0)