Skip to content

Commit

Permalink
added generator test
Browse files Browse the repository at this point in the history
  • Loading branch information
czaloom committed Nov 13, 2024
1 parent c974f41 commit 829a44b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lite/tests/semantic_segmentation/test_annotation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import numpy as np
import pytest
from valor_lite.semantic_segmentation import Bitmask, Segmentation
from valor_lite.semantic_segmentation import (
Bitmask,
Segmentation,
generate_segmentation,
)


def test_bitmask():
Expand Down Expand Up @@ -78,3 +82,25 @@ def test_segmentation():
predictions=[],
)
assert "missing predictions" in str(e)


def test_generate_segmentation():

segmentation = generate_segmentation(
datum_uid="uid1",
number_of_unique_labels=3,
mask_height=2,
mask_width=3,
)

assert segmentation.uid == "uid1"
assert segmentation.shape == (2, 3)
assert segmentation.size == 6

assert len(segmentation.groundtruths) == 3
assert all(gt.mask.dtype == np.bool_ for gt in segmentation.groundtruths)
assert all(gt.mask.shape == (2, 3) for gt in segmentation.groundtruths)

assert len(segmentation.predictions)
assert all(pd.mask.dtype == np.bool_ for pd in segmentation.predictions)
assert all(pd.mask.shape == (2, 3) for pd in segmentation.predictions)

0 comments on commit 829a44b

Please sign in to comment.