|
19 | 19 |
|
20 | 20 | from six import string_types
|
21 | 21 |
|
22 |
| -logging.captureWarnings(False) |
23 |
| -warnings.simplefilter('always', UserWarning) |
24 |
| - |
25 | 22 |
|
26 | 23 | class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)):
|
27 | 24 |
|
@@ -92,6 +89,7 @@ def fit(self, X, y):
|
92 | 89 | self.logger.debug('Shall we raise a warning: %s',
|
93 | 90 | np.unique(y).size == 1)
|
94 | 91 | if np.unique(y).size == 1:
|
| 92 | + warnings.simplefilter('always', UserWarning) |
95 | 93 | warnings.warn('Only one class detected, something will get wrong')
|
96 | 94 | self.logger.debug('The warning should has been raised.')
|
97 | 95 |
|
@@ -262,6 +260,7 @@ def fit(self, X, y):
|
262 | 260 |
|
263 | 261 | # Check that the target type is binary
|
264 | 262 | if not type_of_target(y) == 'binary':
|
| 263 | + warnings.simplefilter('always', UserWarning) |
265 | 264 | warnings.warn('The target type should be binary.')
|
266 | 265 |
|
267 | 266 | return self
|
@@ -298,6 +297,7 @@ def fit(self, X, y):
|
298 | 297 | # Check that the target type is either binary or multiclass
|
299 | 298 | if not (type_of_target(y) == 'binary' or
|
300 | 299 | type_of_target(y) == 'multiclass'):
|
| 300 | + warnings.simplefilter('always', UserWarning) |
301 | 301 | warnings.warn('The target type should be binary or multiclass.')
|
302 | 302 |
|
303 | 303 | return self
|
0 commit comments