File: test_base.py

package info (click to toggle)
python-imgviz 1.7.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,056 kB
  • sloc: python: 3,131; makefile: 25
file content (22 lines) | stat: -rw-r--r-- 507 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pathlib

import numpy as np

import imgviz


def test_lblsave(tmp_path: pathlib.Path) -> None:
    data: dict = imgviz.data.arc2017()

    label_cls: np.ndarray = data["class_label"]

    assert label_cls.min() == 0
    assert label_cls.max() == 25

    label_cls = label_cls.astype(np.uint8)

    png_file: pathlib.Path = tmp_path / "label_cls.png"
    imgviz.io.lblsave(png_file, label_cls)
    label_cls_read = imgviz.io.imread(png_file)

    np.testing.assert_allclose(label_cls, label_cls_read)