def test_get_feature_names_out(_varnames, _drop, df_vartypes): # set up transformer transformer = MathFeatures( variables=["Age", "Marks"], func=["sum", "mean"], new_variables_names=_varnames, drop_original=_drop, ) # fit transformer X = transformer.fit_transform(df_vartypes) # assert functionality assert list( X.columns) == transformer.get_feature_names_out(input_features=None) assert list( X.columns) == transformer.get_feature_names_out(input_features=False) if _varnames is not None: assert _varnames == transformer.get_feature_names_out( input_features=True) else: assert ["sum_Age_Marks", "mean_Age_Marks" ] == transformer.get_feature_names_out(input_features=True)
def test_get_feature_names_out_raises_error_when_wrong_param( _input_features, df_vartypes): transformer = MathFeatures( variables=["Age", "Marks"], func=["sum", "mean"], ) transformer.fit(df_vartypes) with pytest.raises(ValueError): transformer.get_feature_names_out(input_features=_input_features)