Exemplo n.º 1
0
def test_error_when_division_by_zero(_func, df_vartypes):

    df_zero = df_vartypes.copy()
    df_zero.loc[1, "Marks"] = 0

    transformer = RelativeFeatures(
        variables=["Age"],
        reference=["Marks"],
        func=_func,
    )
    transformer.fit(df_vartypes)
    with pytest.raises(ValueError):
        transformer.transform(df_zero)
Exemplo n.º 2
0
def test_error_when_null_values_in_variable(df_vartypes):

    df_na = df_vartypes.copy()
    df_na.loc[1, "Age"] = np.nan

    transformer = RelativeFeatures(
        variables=["Age", "Marks"],
        reference=["Age", "Marks"],
        func=["add", "mul"],
        missing_values="raise",
    )

    with pytest.raises(ValueError):
        transformer.fit(df_na)

    transformer.fit(df_vartypes)
    with pytest.raises(ValueError):
        transformer.transform(df_na)