Example #1
0
def test_random_brightness_scale_outside_range_positive():
    img = np.ones((1, 1, 3)) * 1024
    zeros = np.zeros((1, 1, 3))
    must_be_1024 = affine_transformations.random_brightness(img, [1, 1], False)
    assert np.array_equal(img, must_be_1024)
    must_be_0 = affine_transformations.random_brightness(img, [1, 1], True)
    assert np.array_equal(zeros, must_be_0)
Example #2
0
def test_random_brightness_scale():
    img = np.ones((1, 1, 3)) * 128
    zeros = np.zeros((1, 1, 3))
    must_be_128 = affine_transformations.random_brightness(img, [1, 1], False)
    assert np.array_equal(img, must_be_128)
    must_be_0 = affine_transformations.random_brightness(img, [1, 1], True)
    assert np.array_equal(zeros, must_be_0)
Example #3
0
def test_random_brightness_error():
    with pytest.raises(ValueError):
        affine_transformations.random_brightness(0, [0])
Example #4
0
def test_random_brightness(monkeypatch):
    monkeypatch.setattr(affine_transformations, 'apply_brightness_shift',
                        lambda x, y: (x, y))
    assert (0, 3.) == affine_transformations.random_brightness(0, (3, 3))