def test_error_when_inverse_transform_not_implemented(transformer):
    X = fetch_california_housing(as_frame=True).frame
    y = X["MedHouseVal"]
    X = X.drop(["MedHouseVal"], axis=1)

    tr_wrap = SklearnTransformerWrapper(transformer=transformer)
    tr_wrap.fit(X, y)
    X_tr = tr_wrap.transform(X)

    with pytest.raises(NotImplementedError):
        tr_wrap.inverse_transform(X_tr)
def test_inverse_transform(transformer):
    X = fetch_california_housing(as_frame=True).frame
    X = X.drop(["Longitude"], axis=1)

    tr_wrap = SklearnTransformerWrapper(transformer=transformer)

    # When passing variable list
    varlist = ["MedInc", "HouseAge", "AveRooms", "AveBedrms"]
    tr_wrap.set_params(variables=varlist)
    X_tr = tr_wrap.fit_transform(X)
    X_inv = tr_wrap.inverse_transform(X_tr)

    pd.testing.assert_frame_equal(X_inv, X)

    # when variable list is None
    tr_wrap.set_params(variables=None)

    X_tr = tr_wrap.fit_transform(X)
    X_inv = tr_wrap.inverse_transform(X_tr)

    pd.testing.assert_frame_equal(X_inv, X)