Beispiel #1
0
def test_check_y_not_int_not_float(wage_X_y, wage_gam):
    """y must be int or float, or we should get a value error"""
    X, y = wage_X_y
    y_str = ['hi'] * len(y)

    with pytest.raises(ValueError):
        check_y(y_str, wage_gam.link, wage_gam.distribution)
Beispiel #2
0
def test_check_y_not_int_not_float(wage_X_y, wage_gam):
    """y must be int or float, or we should get a value error"""
    X, y = wage_X_y
    y_str = ['hi'] * len(y)
    try:
        check_y(y_str, wage_gam.link, wage_gam.distribution)
        assert False
    except ValueError:
        check_y(y, wage_gam.link, wage_gam.distribution)
        assert (True)
Beispiel #3
0
def test_check_y_not_in_domain_link(default_X_y, default_gam):
    """if you give labels outide of the links domain, check_y will raise an error"""
    X, y = default_X_y
    gam = default_gam

    with pytest.raises(ValueError):
        check_y(y + .1,
                default_gam.link,
                default_gam.distribution,
                verbose=False)
Beispiel #4
0
def test_check_y_not_min_samples(wage_X_y, wage_gam):
    """check_y expects a minimum number of samples"""
    X, y = wage_X_y

    with pytest.raises(ValueError):
        check_y(y,
                wage_gam.link,
                wage_gam.distribution,
                min_samples=len(y) + 1,
                verbose=False)
Beispiel #5
0
def test_check_y_not_in_doamin_link(default, default_gam):
    """if you give labels outide of the links domain, check_y will raise an error"""
    X, y = default
    gam = default_gam

    try:
        check_y(y + .1, default_gam.link, default_gam.distribution)
        assert False
    except ValueError:
        check_y(y, default_gam.link, default_gam.distribution)
        assert True
Beispiel #6
0
def test_check_y_not_min_samples(wage, wage_gam):
    """check_y expects a minimum number of samples"""
    X, y = wage
    try:
        check_y(y,
                wage_gam.link,
                wage_gam.distribution,
                min_samples=len(y) + 1)
        assert False
    except ValueError:
        check_y(y, wage_gam.link, wage_gam.distribution, min_samples=len(y))
        assert True
Beispiel #7
0
def test_check_y_casts_to_numerical(wage_X_y, wage_gam):
    """check_y will try to cast data to numerical types"""
    X, y = wage_X_y
    y = y.astype('object')

    y = check_y(y, wage_gam.link, wage_gam.distribution)
    assert y.dtype == 'float'