Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shrivaths16 committed Mar 14, 2024
1 parent dc1457f commit 5c655b2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Binary file added tests/data/hdf5_format_v1/single_fly.h5
Binary file not shown.
Binary file added tests/data/videos/single_fly.mp4
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/fixtures/videos.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import pytest

from sleap.io.video import Video
from sleap.io.format.filehandle import FileHandle

TEST_H5_FILE = "tests/data/hdf5_format_v1/training.scale=0.50,sigma=10.h5"
TEST_H5_DSET = "/box"
TEST_H5_CONFMAPS = "/confmaps"
TEST_H5_AFFINITY = "/pafs"
TEST_H5_INPUT_FORMAT = "channels_first"
TEST_SINGLE_FLY_H5 = "tests/data/hdf5_format_v1/single_fly.h5"


@pytest.fixture
def single_fly_hdf5():
return FileHandle(filename=TEST_SINGLE_FLY_H5)


@pytest.fixture
Expand Down Expand Up @@ -42,6 +49,12 @@ def hdf5_affinity():

TEST_SMALL_ROBOT_MP4_FILE = "tests/data/videos/small_robot.mp4"
TEST_SMALL_CENTERED_PAIR_VID = "tests/data/videos/centered_pair_small.mp4"
TEST_SINGLE_FLY = "tests/data/videos/single_fly.mp4"


@pytest.fixture
def single_fly_mp4_vid():
return Video.from_media(TEST_SINGLE_FLY)


@pytest.fixture
Expand Down
13 changes: 13 additions & 0 deletions tests/io/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
from sleap.gui.app import MainWindow
from sleap.gui.state import GuiState
from sleap.info.write_tracking_h5 import get_nodes_as_np_strings
from sleap.io.format.sleap_analysis import SleapAnalysisAdaptor


def test_sleap_analysis_read(single_fly_mp4_vid, single_fly_hdf5):

# Single instance hdf5 analysis file test
read_labels = SleapAnalysisAdaptor.read(
file=single_fly_hdf5, video=single_fly_mp4_vid
)

assert len(read_labels.videos) == 1
assert len(read_labels.tracks) == 1
assert len(read_labels.skeletons) == 1


def test_text_adaptor(tmpdir):
Expand Down

0 comments on commit 5c655b2

Please sign in to comment.