Skip to content

Commit 19be425

Browse files
chkoarGuillaume Lemaitre
authored andcommitted
Get logger in fit and sample using private method
1 parent ed88516 commit 19be425

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

imblearn/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, ratio='auto'):
4747
"""
4848

4949
self.ratio = ratio
50-
self.logger = logging.getLogger(__name__)
50+
5151

5252
def fit(self, X, y):
5353
"""Find the classes statistics before to perform sampling.
@@ -69,6 +69,8 @@ def fit(self, X, y):
6969

7070
# Check the consistency of X and y
7171
X, y = check_X_y(X, y)
72+
73+
self._get_logger()
7274

7375
self.min_c_ = None
7476
self.maj_c_ = None
@@ -138,6 +140,8 @@ def sample(self, X, y):
138140

139141
# Check the consistency of X and y
140142
X, y = check_X_y(X, y)
143+
144+
self._get_logger()
141145

142146
# Check that the data have been fitted
143147
if not hasattr(self, 'stats_c_'):
@@ -220,3 +224,7 @@ def __getstate__(self):
220224
object_dictionary = self.__dict__.copy()
221225
del object_dictionary['logger']
222226
return object_dictionary
227+
228+
229+
def _get_logger(self):
230+
self.logger = logging.getLogger(__name__)

0 commit comments

Comments
 (0)