File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 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):
163163 for t in transformers :
164164 if t is None or t == "passthrough" :
165165 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 :
171172 raise TypeError (
172173 "All intermediate steps of the chain should "
173174 "be estimators that implement fit and transform or "
174175 "fit_resample (but not both) or be a string 'passthrough' "
175176 "'%s' (type %s) doesn't)" % (t , type (t ))
176177 )
177178
178- if hasattr (t , "fit_resample" ) and (
179- hasattr (t , "fit_transform" ) or hasattr (t , "transform" )
180- ):
179+ if is_transfomer and is_sampler :
181180 raise TypeError (
182181 "All intermediate steps of the chain should "
183182 "be estimators that implement fit and transform or "
You can’t perform that action at this time.
0 commit comments