def test_get_feature_names_out_raises_when_input_features_is_string(df_time): tr = ExpandingWindowFeatures(functions=["mean", "sum"]) tr.fit(df_time) with pytest.raises(ValueError): # get error when user does not pass a list tr.get_feature_names_out(input_features="ambient_temp")
def test_get_feature_names_out_raises_when_input_features_not_transformed( df_time): tr = ExpandingWindowFeatures(functions=["mean", "sum"]) tr.fit(df_time) with pytest.raises(ValueError): # assert error when uses passes features that were not transformed tr.get_feature_names_out(input_features=["color"])
def test_get_feature_names_out_single_variable_and_single_function(df_time): # input features original_features = ["ambient_temp", "module_temp", "irradiation", "color"] tr = ExpandingWindowFeatures(variables="ambient_temp", functions="sum") tr.fit(df_time) # expected output = [ "ambient_temp_expanding_sum", ] assert tr.get_feature_names_out( input_features=None) == original_features + output assert tr.get_feature_names_out(input_features=["ambient_temp"]) == output
def test_get_feature_names_out_multiple_variables_and_functions(df_time): # input features input_features = ["ambient_temp", "module_temp", "irradiation"] original_features = ["ambient_temp", "module_temp", "irradiation", "color"] tr = ExpandingWindowFeatures(functions=["mean", "sum"]) tr.fit(df_time) # expected output = [ "ambient_temp_expanding_mean", "ambient_temp_expanding_sum", "module_temp_expanding_mean", "module_temp_expanding_sum", "irradiation_expanding_mean", "irradiation_expanding_sum", ] assert tr.get_feature_names_out( input_features=None) == original_features + output assert tr.get_feature_names_out(input_features=input_features) == output assert tr.get_feature_names_out( input_features=input_features[0:2]) == output[0:4] assert tr.get_feature_names_out( input_features=[input_features[0]]) == output[0:2]