Beispiel #1
0
def test_scoring_function_argument():
    with captured_output() as (out, err):
        # regular argument returns regular string
        assert_equal(load_scoring_function("roc_auc"), "roc_auc")

        # bad function returns exception
        assert_raises(Exception,
                      load_scoring_function,
                      scoring_func="tests.__fake_BAD_FUNC_NAME")

        # manual function loads the function
        assert_equal(
            load_scoring_function(
                'driver_tests.test_scoring_function_argument').__name__,
            test_scoring_function_argument.__name__)

        # installed-module function test
        assert_equal(
            load_scoring_function('sklearn.metrics.auc').__name__, "auc")

        out, err = out.getvalue(), err.getvalue()

    assert_in("failed importing custom scoring function", out)
    assert_in("manual scoring function: <function auc", out)
    assert_in("taken from module: sklearn.metrics", out)
    assert_in(
        "manual scoring function: <function test_scoring_function_argument",
        out)
    assert_in("taken from module: driver_tests", out)
    assert_equal(err, "")
Beispiel #2
0
def test_scoring_function_argument():
    with captured_output() as (out, err):
        # regular argument returns regular string
        assert_equal(load_scoring_function("roc_auc"), "roc_auc")

        # bad function returns exception
        assert_raises(Exception, load_scoring_function, scoring_func="tests.__fake_BAD_FUNC_NAME")

        # manual function loads the function
        assert_equal(load_scoring_function('driver_tests.test_scoring_function_argument').__name__, test_scoring_function_argument.__name__)

        # installed-module function test
        assert_equal(load_scoring_function('sklearn.metrics.auc').__name__, "auc")

        out, err = out.getvalue(), err.getvalue()

    assert_in("failed importing custom scoring function", out)
    assert_in("manual scoring function: <function auc", out)
    assert_in("taken from module: sklearn.metrics", out)
    assert_in("manual scoring function: <function test_scoring_function_argument", out)
    assert_in("taken from module: driver_tests", out)
    assert_equal(err, "")