Skip to content

Commit

Permalink
Add minimal unit tests for vak.transforms.frame_labels.functional.bou…
Browse files Browse the repository at this point in the history
…ndary_inds_from_boundary_labels
  • Loading branch information
NickleDave committed Sep 9, 2024
1 parent 02974d3 commit a07f17b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_transforms/test_frame_labels/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,45 @@ def test_to_segments_real_data(
assert np.all(np.abs(annot.seq.offsets_s - offsets_s) < MAX_ABS_DIFF)


@pytest.mark.parametrize(
"boundary_labels, boundary_inds_expected",
[
(
np.array([1,0,0,0,1,0,0]),
np.array([0,4])
),
]
)
def test_boundary_inds_from_boundary_labels(boundary_labels, boundary_inds_expected):
boundary_inds = vak.transforms.frame_labels.boundary_inds_from_boundary_labels(
boundary_labels
)
assert np.array_equal(boundary_inds, boundary_inds_expected)


@pytest.mark.parametrize(
"boundary_labels, expected_exception",
[
# 3-d array should raise a ValueError, needs to be row or 1-d
(
np.array([[[1,0,0,0,1,0,0]]]),
ValueError
),
# column vector should raise a ValueError, needs to be row or 1-d
(
np.array([[1],[0],[0]]),
ValueError
)
]
)
def test_boundary_inds_from_boundary_labels(boundary_labels, expected_exception):
with pytest.raises(expected_exception):
vak.transforms.frame_labels.functional.segment_inds_list_from_boundary_labels(
boundary_labels
)


@pytest.mark.parametrize(
"frame_labels, seg_inds_list_expected",
[
Expand Down

0 comments on commit a07f17b

Please sign in to comment.