def test_plot_normal(X_y, clf):
    """
    Test.
    """
    plotter = DependencePlotter(clf).fit(X_y[0], X_y[1])
    for binning in ["simple", "agglomerative", "quantile"]:
        _ = plotter.plot(feature=0, type_binning=binning)
def test_plot_class_names(X_y, clf):
    """
    Test.
    """
    plotter = DependencePlotter(clf).fit(X_y[0],
                                         X_y[1],
                                         class_names=["a", "b"])
    _ = plotter.plot(feature=0)
    assert plotter.class_names == ["a", "b"]
def test_plot_input(X_y, clf):
    """
    Test.
    """
    plotter = DependencePlotter(clf).fit(X_y[0], X_y[1])
    with pytest.raises(ValueError):
        plotter.plot(feature="not a feature")
    with pytest.raises(ValueError):
        plotter.plot(feature=0, type_binning=5)
    with pytest.raises(ValueError):
        plotter.plot(feature=0, min_q=1, max_q=0)
def test_fit_complex(complex_data_split, complex_fitted_lightgbm):
    """
    Test.
    """
    X_train, X_test, y_train, y_test = complex_data_split

    plotter = DependencePlotter(complex_fitted_lightgbm)

    plotter.fit(X_test, y_test)

    pd.testing.assert_frame_equal(plotter.X, X_test)
    pd.testing.assert_series_equal(plotter.y,
                                   pd.Series(y_test, index=X_test.index))
    assert plotter.fitted is True

    # Check if plotting doesnt cause errors
    with patch("matplotlib.pyplot.figure") as _:
        for binning in ["simple", "agglomerative", "quantile"]:
            _ = plotter.plot(feature="f2_missing", type_binning=binning)