Skip to content

Commit

Permalink
Change the unique checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Lemaitre committed Oct 18, 2016
1 parent f761722 commit 3d90e5a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions imblearn/base.py
Expand Up @@ -81,14 +81,11 @@ def fit(self, X, y):

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

# Get all the unique elements in the target array
uniques = np.unique(y)

# # Raise an error if there is only one class
# if uniques.size == 1:
# raise RuntimeError("Only one class detected, aborting...")
# Raise a warning for the moment to be compatible with BaseEstimator
if uniques.size == 1:
if np.unique(y).size == 1:
warnings.warn('Only one class detected, something will get wrong',
RuntimeWarning)

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

self.logger.info('%s classes detected: %s', uniques.size,
self.logger.info('%s classes detected: %s', np.unique(y).size,
self.stats_c_)

# Check if the ratio provided at initialisation make sense
Expand Down

0 comments on commit 3d90e5a

Please sign in to comment.