File: test_centerize.py

package info (click to toggle)
python-imgviz 1.2.4%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,268 kB
  • sloc: python: 3,032; makefile: 15
file content (21 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import numpy as np

import imgviz


def test_centerize():
    img = np.random.uniform(0, 255, size=(15, 25, 3)).round().astype(np.uint8)

    dst = imgviz.centerize(img, shape=(25, 25), cval=0)
    assert dst.shape == (25, 25, 3)
    assert dst.dtype == img.dtype
    assert (dst[:5] == 0).all()
    assert (dst[-5:] == 0).all()
    np.testing.assert_allclose(dst[5:-5], img)

    dst = imgviz.centerize(img, shape=(15, 35), cval=0)
    assert dst.shape == (15, 35, 3)
    assert dst.dtype == img.dtype
    assert (dst[:, :5] == 0).all()
    assert (dst[:, -5:] == 0).all()
    np.testing.assert_allclose(dst[:, 5:-5], img)