def test_one_or_other(): first = MagicMock() second = MagicMock() augmentation = OneOrOther(first, second, p=1) image = np.ones((8, 8)) augmentation(image=image) assert first.called != second.called
def test_deterministic_one_or_other(): aug = ReplayCompose([OneOrOther(HorizontalFlip(), Blur())], p=1) for i in range(10): image = (np.random.random((8, 8)) * 255).astype(np.uint8) image2 = np.copy(image) data = aug(image=image) assert "replay" in data data2 = ReplayCompose.replay(data["replay"], image=image2) assert np.array_equal(data["image"], data2["image"])