def test_clipping(iris_dataset):
    """
    Check weather adversaries are clipped properly.
    """
    (x_train, y_train, x_valid, y_valid), _, clip_values = iris_dataset

    # Setup classifier
    lr_clf = LogisticRegression(penalty=None)
    lr_clf.fit(x_train, y_train)

    # Dataset min-max clipping values
    bottom_min, top_max = clip_values
    clf_slr_min_max = ScikitlearnLogisticRegression(model=lr_clf, clip_values=(bottom_min, top_max))

    # Clip values
    bottom_custom = -3
    top_custom = 3
    clf_slr_custom = ScikitlearnLogisticRegression(model=lr_clf, clip_values=(bottom_custom, top_custom))

    # Setting up LowProFool classes with different hyperparameters
    lpf_min_max_default = LowProFool(classifier=clf_slr_min_max, n_steps=45, eta=0.02, lambd=1.5)
    lpf_min_max_high_eta = LowProFool(classifier=clf_slr_min_max, n_steps=45, eta=100000, lambd=1.5)
    lpf_custom_default = LowProFool(classifier=clf_slr_custom, n_steps=45, eta=0.02, lambd=1.5)
    lpf_custom_high_eta = LowProFool(classifier=clf_slr_custom, n_steps=45, eta=100000, lambd=1.5)

    lpf_min_max_default.fit_importances(x_train, y_train)
    lpf_min_max_high_eta.fit_importances(x_train, y_train)
    lpf_custom_default.fit_importances(x_train, y_train)
    lpf_custom_high_eta.fit_importances(x_train, y_train)

    # Generating adversaries
    sample = np.array([[5.5, 2.4, 3.7, 1.0]])
    target = np.array([[0.0, 0.0, 1.0]])

    adversaries_min_max_default = lpf_min_max_default.generate(x=sample, y=target)
    adversaries_min_max_high_eta = lpf_min_max_high_eta.generate(x=sample, y=target)
    adversaries_custom_default = lpf_custom_default.generate(x=sample, y=target)
    adversaries_custom_high_eta = lpf_custom_high_eta.generate(x=sample, y=target)

    # Checking whether adversaries were clipped properly
    eps = 1e-6
    is_valid_1 = ((bottom_min - eps).to_numpy() <= adversaries_min_max_default).all() and (
        (top_max + eps).to_numpy() >= adversaries_min_max_default
    ).all()
    is_valid_2 = ((bottom_min - eps).to_numpy() <= adversaries_min_max_high_eta).all() and (
        (top_max + eps).to_numpy() >= adversaries_min_max_high_eta
    ).all()
    is_valid_3 = ((bottom_custom - eps) <= adversaries_custom_default).all() and (
        (top_custom + eps) >= adversaries_custom_default
    ).all()
    is_valid_4 = (bottom_custom - eps <= adversaries_custom_high_eta).all() and (
        top_custom + eps >= adversaries_custom_high_eta
    ).all()

    is_clipping_valid = is_valid_1 and is_valid_2 and is_valid_3 and is_valid_4
    if is_clipping_valid:
        logger.info("[Iris flower, Scikit-learn Logistic Regression] Clipping is valid.")
    else:
        logger.info("[Iris flower, Scikit-learn Logistic Regression] Clipping is invalid.")

    assert is_valid_1
    assert is_valid_2
    assert is_valid_3
    assert is_valid_4

    Check weather adversaries are clipped properly.
    
tests/attacks/evasion/test_lowprofool.py