Beispiel #1
0
def test_slize_batches():
    image_ids = [0, 1, 2, 3]

    batch_size = 1
    expected_result = [[0], [1], [2], [3]]
    assert (expected_result == slize_batches(image_ids, batch_size)).all()

    batch_size = 2
    expected_result = [[0, 1], [2, 3]]
    assert (expected_result == slize_batches(image_ids, batch_size)).all()

    batch_size = 3
    expected_result = [[0, 1, 2]]
    assert (expected_result == slize_batches(image_ids, batch_size)).all()
Beispiel #2
0
def test_slice_batches_invalid_argument_batch_size():
    image_ids = [0, 1, 2, 3]

    with pytest.raises(TypeError):
        batch_size = "not an integer"
        slize_batches(image_ids, batch_size)
Beispiel #3
0
def test_slice_batches_invalid_argument_image_ids():
    with pytest.raises(TypeError):
        image_ids = "not a list"
        slize_batches(image_ids)
Beispiel #4
0
def test_slice_batches_invalid_large_batch_size():
    image_ids = [0, 1, 2, 3]

    with pytest.raises(ValueError):
        batch_size = 5
        slize_batches(image_ids, batch_size)