Пример #1
0
def test_compute_compressed_budgets():
    """Verify proper computation of budgets when scale is small and integer rounding creates
    duplicates
    """
    assert compute_budgets(1, 16, 2, 10) == [1, 2, 3, 4, 5, 6, 7, 9, 12, 16]

    with pytest.raises(ValueError) as exc:
        compute_budgets(1, 2, 2, 10)

    assert "Cannot build budgets below max_resources" in str(exc.value)
Пример #2
0
def test_compute_budgets():
    """Verify proper computation of budgets on a logarithmic scale"""
    # Check typical values
    assert compute_budgets(1, 16, 4, 3) == [1, 4, 16]
    # Check rounding (max_resources is not a multiple of reduction_factor)
    assert compute_budgets(1, 30, 4, 3) == [1, 5, 30]
    # Check rounding (min_resources may be rounded below its actual value)
    assert compute_budgets(25, 1000, 2, 6) == [25, 52, 109, 229, 478, 1000]
    # Check min_resources
    assert compute_budgets(5, 125, 5, 3) == [5, 25, 125]
    # Check num_rungs
    assert compute_budgets(1, 16, 2, 5) == [1, 2, 4, 8, 16]
Пример #3
0
def test_compute_budgets():
    """Verify proper computation of budgets on a logarithmic scale"""
    # Check typical values
    assert compute_budgets(1, 16, 4, 3, 1) == [[(16, 1), (4, 4), (1, 16)]]
    # Check rounding (max_resources is not a multiple of reduction_factor)
    assert compute_budgets(1, 30, 4, 3, 1) == [[(16, 1), (4, 5), (1, 30)]]
    # Check rounding (min_resources may be rounded below its actual value)
    assert compute_budgets(25, 1000, 2, 6,
                           1) == [[(32, 25), (16, 52), (8, 109), (4, 229),
                                   (2, 478), (1, 1000)]]
    # Check min_resources
    assert compute_budgets(5, 125, 5, 3, 1) == [[(25, 5), (5, 25), (1, 125)]]
    # Check num_rungs
    assert compute_budgets(1, 16, 2, 5, 1) == [[(16, 1), (8, 2), (4, 4),
                                                (2, 8), (1, 16)]]
Пример #4
0
def test_compute_compressed_budgets():
    """Verify proper computation of budgets when scale is small and integer rounding creates
    duplicates
    """
    assert compute_budgets(1, 16, 2, 10, 1) == [[
        (512, 1),
        (256, 2),
        (128, 3),
        (64, 4),
        (32, 5),
        (16, 6),
        (8, 7),
        (4, 9),
        (2, 12),
        (1, 16),
    ]]

    with pytest.raises(ValueError) as exc:
        compute_budgets(1, 2, 2, 10, 1)

    assert "Cannot build budgets below max_resources" in str(exc.value)