"""Checks of descriptor geometry and edge-orientation behavior.""" import numpy as np from features import descriptor black = np.zeros((1, 3, 32, 32), dtype=np.uint8) assert descriptor(black).shape == (1, 2048) assert not descriptor(black).any() vertical = np.broadcast_to(np.arange(32, dtype=np.uint8)[None, None, None, :] * 8, (1, 3, 32, 32)) horizontal = vertical.transpose(0, 1, 3, 2) v, h = descriptor(vertical), descriptor(horizontal) assert v.any() and h.any() and not np.array_equal(v, h) assert (v[:, 1764:] == 0).all() assert (descriptor(vertical, hybrid=True)[:, 1940:] == 0).all() assert np.array_equal(v, descriptor(vertical.copy())) assert (np.count_nonzero(descriptor(vertical, sparse=True), axis=1) <= 256).all() print('Feature geometry, orientation, padding and determinism checks passed')