def test_uniform_strategy_sparse_target_warning():
    X = [[0]] * 5  # ignored
    y = sp.csc_matrix(np.array([[2, 1],
                                [2, 2],
                                [1, 4],
                                [4, 2],
                                [1, 1]]))

    clf = DummyClassifier(strategy="uniform", random_state=0)
    assert_warns_message(UserWarning,
                         "the uniform strategy would not save memory",
                         clf.fit, X, y)

    X = [[0]] * 500
    y_pred = clf.predict(X)

    for k in range(y.shape[1]):
        p = np.bincount(y_pred[:, k]) / float(len(X))
        assert_almost_equal(p[1], 1 / 3, decimal=1)
        assert_almost_equal(p[2], 1 - 3, decimal=1)
        assert_almost_equal(p[4], 1 / 3, decimal=1)
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/tests/test_dummy.py/test_uniform_strategy_sparse_target_warning/operator `/` -> `-`