File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -163,21 +163,20 @@ def _validate_steps(self):
163
163
for t in transformers :
164
164
if t is None or t == "passthrough" :
165
165
continue
166
- if not (
167
- hasattr (t , "fit" )
168
- or hasattr (t , "fit_transform" )
169
- or hasattr (t , "fit_resample" )
170
- ) or not (hasattr (t , "transform" ) or hasattr (t , "fit_resample" )):
166
+
167
+ is_transfomer = hasattr (t , "fit" ) and hasattr (t , "transform" )
168
+ is_sampler = hasattr (t , "fit_resample" )
169
+ is_not_transfomer_or_sampler = not (is_transfomer or is_sampler )
170
+
171
+ if is_not_transfomer_or_sampler :
171
172
raise TypeError (
172
173
"All intermediate steps of the chain should "
173
174
"be estimators that implement fit and transform or "
174
175
"fit_resample (but not both) or be a string 'passthrough' "
175
176
"'%s' (type %s) doesn't)" % (t , type (t ))
176
177
)
177
178
178
- if hasattr (t , "fit_resample" ) and (
179
- hasattr (t , "fit_transform" ) or hasattr (t , "transform" )
180
- ):
179
+ if is_transfomer and is_sampler :
181
180
raise TypeError (
182
181
"All intermediate steps of the chain should "
183
182
"be estimators that implement fit and transform or "
You can’t perform that action at this time.
0 commit comments