File size: 925 Bytes
5d31c67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np

import evaluate as ev


def test_dihedral_transforms_invert_for_2d_and_3d():
    rng = np.random.default_rng(0)
    a2 = rng.random((5, 7))
    a3 = rng.random((3, 5, 7))
    for k, f in ev.DIHEDRAL:
        assert np.array_equal(ev.inv_np(ev.fwd_np(a2, k, f), k, f), a2)
        assert np.array_equal(ev.inv_np(ev.fwd_np(a3, k, f), k, f), a3)


def test_dihedral_transforms_are_distinct():
    a = np.arange(12).reshape(3, 4).astype(float)
    outs = [ev.fwd_np(a, k, f).tobytes() + bytes(ev.fwd_np(a, k, f).shape) for k, f in ev.DIHEDRAL]
    assert len(set(outs)) == 8


def test_photometric_is_deterministic_and_valid():
    img = (np.random.default_rng(1).random((16, 16, 3)) * 255).astype(np.uint8)
    a = ev.photometric(img, 5)
    b = ev.photometric(img, 5)
    assert np.array_equal(a, b) and a.dtype == np.uint8 and a.shape == img.shape
    assert not np.array_equal(ev.photometric(img, 6), a)