Module test_steal
source linkFunctions
▷ def test_balance(inp, expected) @pytest.mark.parametrize( "inp,expected", [ ([[1], []], [[1], []]), # don't move unnecessarily ([[0, 0], []], [[0], [0]]), # balance ([[0.1, 0.1], []], [[0], [0]]), # balance even if results in even ([[0, 0, 0], []], [[0, 0], [0]]), # don't over balance ([[0, 0], [0, 0, 0], []], [[0, 0], [0, 0], [0]]), # move from larger ([[0, 0, 0], [0], []], [[0, 0], [0], [0]]), # move to smaller ([[0, 1], []], [[1], [0]]), # choose easier first ([[0, 0, 0, 0], [], []], [[0, 0], [0], [0]]), # spread evenly ([[1, 0, 2, 0], [], []], [[2, 1], [0], [0]]), # move easier ([[1, 1, 1], []], [[1, 1], [1]]), # be willing to move costly items ([[1, 1, 1, 1], []], [[1, 1, 1], [1]]), # but don't move too many ( [[0, 0], [0, 0], [0, 0], []], # no one clearly saturated [[0, 0], [0, 0], [0], [0]], ), ( [[4, 2, 2, 2, 2, 1, 1], [4, 2, 1, 1], [], [], []], [[4, 2, 2, 2, 2], [4, 2, 1], [1], [1], [1]], ), pytest.param( [[1, 1, 1, 1, 1, 1, 1], [1, 1], [1, 1], [1, 1], []], [[1, 1, 1, 1, 1], [1, 1], [1, 1], [1, 1], [1, 1]], marks=pytest.mark.xfail( reason="Some uncertainty based on executing stolen task" ), ), ], ) @pytest.mark.parametrize( "inp,expected", [ ([[1], []], [[1], []]), # don't move unnecessarily ([[0, 0], []], [[0], [0]]), # balance ([[0.1, 0.1], []], [[0], [0]]), # balance even if results in even ([[0, 0, 0], []], [[0, 0], [0]]), # don't over balance ([[0, 0], [0, 0, 0], []], [[0, 0], [0, 0], [0]]), # move from larger ([[0, 0, 0], [0], []], [[0, 0], [0], [0]]), # move to smaller ([[0, 1], []], [[1], [0]]), # choose easier first ([[0, 0, 0, 0], [], []], [[0, 0], [0], [0]]), # spread evenly ([[1, 0, 2, 0], [], []], [[2, 1], [0], [0]]), # move easier ([[1, 1, 1], []], [[1, 1], [1]]), # be willing to move costly items ([[1, 1, 1, 1], []], [[1, 1, 1], [1]]), # but don't move too many ( [[0, 0], [0, 0], [0, 0], []], # no one clearly saturated [[0, 0], [0, 0], [0], [0]], ), ( [[4, 2, 2, 2, 2, 1, 1], [4, 2, 1, 1], [], [], []], [[4, 2, 2, 2, 2], [4, 2, 1], [1], [1], [1]], ), pytest.param( [[1, 1, 1, 1, 1, 1, 1], [1, 1], [1, 1], [1, 1], []], [[1, 1, 1, 1, 1], [1, 1], [1, 1], [1, 1], [1, 1]], marks=pytest.mark.xfail( reason="Some uncertainty based on executing stolen task" ), ), ], )
def test_balance(
inp,
expected,
)