Exemplo n.º 1
0
def test_gen_subset_indices():
    # generate 5 data sets each with half the data
    subsets = du.gen_subset_indices(20, .5, 5)

    assert len(subsets) == 5
    assert all(len(subset) == 10 for subset in subsets)

    # each element should be unique
    assert all(len(set(subset)) == 10 for subset in subsets)

    allidxs = []
    for subset in subsets:
        allidxs.extend(subset)

    assert len(set(allidxs)) == 20
Exemplo n.º 2
0
def test_gen_subset_indices():
    # generate 5 data sets each with half the data
    subsets = du.gen_subset_indices(20, .5, 5)

    assert len(subsets) == 5
    assert all(len(subset) == 10 for subset in subsets)

    # each element should be unique
    assert all(len(set(subset)) == 10 for subset in subsets)

    allidxs = []
    for subset in subsets:
        allidxs.extend(subset)

    assert len(set(allidxs)) == 20
Exemplo n.º 3
0
def test_gen_subset_indices_raises_value_error_with_high_set_size():
    with pytest.raises(ValueError):
        du.gen_subset_indices(20, 1.2, 5)
Exemplo n.º 4
0
def test_gen_subset_indices_handles_oddly_divisible_sizes():
    subsets = du.gen_subset_indices(23, .5, 5)
    assert len(subsets) == 5
Exemplo n.º 5
0
def test_gen_subset_indices_raises_value_error_with_high_set_size():
    with pytest.raises(ValueError):
        du.gen_subset_indices(20, 1.2, 5)
Exemplo n.º 6
0
def test_gen_subset_indices_handles_oddly_divisible_sizes():
    subsets = du.gen_subset_indices(23, .5, 5)
    assert len(subsets) == 5