All attributes with trailing underscore must be set up at the end of the fit() functionality, when we are sure that all fit logic worked. At the moment, it is not like that for all transformers.
Add a test like the one in test_encoders:
@pytest.mark.parametrize("estimator", _estimators)
def test_raises_non_fitted_error_when_error_during_fit(estimator):
X, y = test_df(categorical=True)
X.loc[len(X) - 1] = nan
transformer = clone(estimator)
with pytest.raises(ValueError):
transformer.fit(X, y)
# Test when fit is not called prior to transform.
with pytest.raises(NotFittedError):
transformer.transform(X)
Modules encoding and preprocessing already have this functionality.
Modules to update:
Related PRs: