| 1 | import pathlib |
| 2 | |
| 3 | import numpy as np |
| 4 | |
| 5 | import imgviz |
| 6 | |
| 7 | |
| 8 | def test_lblsave(tmp_path: pathlib.Path) -> None: |
| 9 | data: dict = imgviz.data.arc2017() |
| 10 | |
| 11 | label_cls: np.ndarray = data["class_label"] |
| 12 | |
| 13 | assert label_cls.min() == 0 |
| 14 | assert label_cls.max() == 25 |
| 15 | |
| 16 | label_cls = label_cls.astype(np.uint8) |
| 17 | |
| 18 | png_file: pathlib.Path = tmp_path / "label_cls.png" |
| 19 | imgviz.io.lblsave(png_file, label_cls) |
| 20 | label_cls_read = imgviz.io.imread(png_file) |
| 21 | |
| 22 | np.testing.assert_allclose(label_cls, label_cls_read) |