Esempio n. 1
0
def test_calc_split_raise():
    dsi = DatasetIndex(5)
    with pytest.raises(ValueError):
        dsi.calc_split(shares=[0.5, 0.5, 0.5])
    with pytest.raises(ValueError):
        dsi.calc_split(shares=[0.5, 0.5, 0.5, 0.5])
    with pytest.raises(ValueError):
        DatasetIndex(2).calc_split(shares=[0.5, 0.5, 0.5])
Esempio n. 2
0
def test_calc_split_correctness_3():
    """ If 'shares' contains 3 elements, then validation subset is non-empty. """
    dsi = DatasetIndex(5)
    _, _, valid_share = dsi.calc_split(shares=[0.5, 0.5, 0])
    assert valid_share == 0
Esempio n. 3
0
def test_calc_split_correctness_2():
    """ If 'shares' contains 2 elements, validation subset is empty. """
    dsi = DatasetIndex(5)
    left = dsi.calc_split(shares=[0.4, 0.6])
    right = (2, 3, 0)
    assert left == right
Esempio n. 4
0
def test_calc_split_correctness_1():
    dsi = DatasetIndex(5)
    assert sum(dsi.calc_split()) == 5