Skip to content

Commit fbe2872

Browse files
author
Guillaume Lemaitre
committed
Change the unique checking
1 parent 032fa7c commit fbe2872

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

imblearn/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ def fit(self, X, y):
8181

8282
self.logger.info('Compute classes statistics ...')
8383

84-
# Get all the unique elements in the target array
85-
uniques = np.unique(y)
86-
8784
# # Raise an error if there is only one class
8885
# if uniques.size == 1:
8986
# raise RuntimeError("Only one class detected, aborting...")
9087
# Raise a warning for the moment to be compatible with BaseEstimator
91-
if uniques.size == 1:
88+
if np.unique(y).size == 1:
9289
warnings.warn('Only one class detected, something will get wrong',
9390
RuntimeWarning)
9491

@@ -103,7 +100,7 @@ def fit(self, X, y):
103100
self.min_c_ = min(self.stats_c_, key=self.stats_c_.get)
104101
self.maj_c_ = max(self.stats_c_, key=self.stats_c_.get)
105102

106-
self.logger.info('%s classes detected: %s', uniques.size,
103+
self.logger.info('%s classes detected: %s', np.unique(y).size,
107104
self.stats_c_)
108105

109106
# Check if the ratio provided at initialisation make sense

0 commit comments

Comments
 (0)