Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and functionality for loading provenance data #14

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sleap_io/io/slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def read_labels(labels_path: str) -> Labels:
instances = read_instances(
labels_path, skeletons, tracks, points, pred_points, format_id
)
metadata = read_metadata(labels_path)
provenance = metadata.get("provenance", dict())

frames = read_hdf5_dataset(labels_path, "frames")
labeled_frames = []
Expand All @@ -259,7 +261,11 @@ def read_labels(labels_path: str) -> Labels:
)

labels = Labels(
labeled_frames=labeled_frames, videos=videos, skeletons=skeletons, tracks=tracks
labeled_frames=labeled_frames,
videos=videos,
skeletons=skeletons,
tracks=tracks,
provenance=provenance,
)

return labels
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/fixtures/slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ def slp_minimal():
def slp_predictions():
"""A more complex example containing predicted instances from multiple tracks and a single video"""
return "tests/data/slp/centered_pair_predictions.slp"


@pytest.fixture
def slp_predictions_with_provenance():
"""The slp file generated with the collab tutorial and sleap version 1.27"""
return "tests/data/slp/tutorial_predictions_version_1.2.7_with_provenance.slp"
7 changes: 7 additions & 0 deletions tests/io/test_slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ def test_read_labels(slp_typical, slp_simple_skel, slp_minimal):

labels = read_labels(slp_minimal)
assert type(labels) == Labels


def test_load_lsp_with_provenance(slp_predictions_with_provenance):
labels = read_labels(slp_predictions_with_provenance)
provenance = labels.provenance
assert type(provenance) == dict
assert provenance["sleap_version"] == "1.2.7"