Skip to content

Commit d4e7aea

Browse files
committed
change _iter semantics; remove unused import
1 parent 30dde87 commit d4e7aea

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

imblearn/pipeline.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
# Christos Aridas
1313
# Guillaume Lemaitre <g.lemaitre58@gmail.com>
1414
# License: BSD
15-
from itertools import filterfalse
16-
1715
from sklearn import pipeline
1816
from sklearn.base import clone
19-
from sklearn.utils import Bunch, _print_elapsed_time
17+
from sklearn.utils import _print_elapsed_time
2018
from sklearn.utils.metaestimators import if_delegate_has_method
2119
from sklearn.utils.validation import check_memory
2220

@@ -170,13 +168,13 @@ def _validate_steps(self):
170168
)
171169

172170
def _iter(
173-
self, with_final=True, filter_passthrough=True, with_resample=False
171+
self, with_final=True, filter_passthrough=True, filter_resample=True
174172
):
175173
it = super()._iter(with_final, filter_passthrough)
176-
if with_resample:
177-
return it
174+
if filter_resample:
175+
return filter(lambda x: not hasattr(x[-1], "fit_resample"), it)
178176
else:
179-
return filterfalse(lambda x: hasattr(x[-1], "fit_resample"), it)
177+
return it
180178

181179
# Estimator interface
182180

@@ -206,7 +204,7 @@ def _fit(self, X, y=None, **fit_params):
206204
name,
207205
transformer) in self._iter(with_final=False,
208206
filter_passthrough=False,
209-
with_resample=True):
207+
filter_resample=False):
210208
if (transformer is None or transformer == 'passthrough'):
211209
with _print_elapsed_time('Pipeline',
212210
self._log_message(step_idx)):
@@ -220,7 +218,7 @@ def _fit(self, X, y=None, **fit_params):
220218
else:
221219
cloned_transformer = clone(transformer)
222220
elif hasattr(memory, "cachedir"):
223-
# joblib < 0.11
221+
# joblib <= 0.11
224222
if memory.cachedir is None:
225223
# we do not clone when caching is disabled to
226224
# preserve backward compatibility

0 commit comments

Comments
 (0)