Skip to content

ensure that all attributes with trailing underscore in fit are leared after the entire logic has succeded #586

@solegalli

Description

@solegalli

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:

  • imputation
  • encoding
  • discretisation
  • outliers
  • transformation
  • scaling
  • creation
  • datetime
  • text
  • selection
  • time series
  • preproc
  • wrappers

Related PRs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions