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

Fix multi-video serialization in SLP #72

Merged
merged 4 commits into from
Jan 11, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "windows-2022", "macos-11"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python: [3.7, 3.9]

name: Tests (${{ matrix.os }}, Python ${{ matrix.python }})
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- attrs
- h5py
- numpy
- conda-forge::opencv
- pip
- pip:
- opencv-python-headless
- "--editable=.[dev]"
2 changes: 1 addition & 1 deletion sleap_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Define package version.
# This is read dynamically by setuptools in pyproject.toml to determine the release version.
__version__ = "0.0.11"
__version__ = "0.0.12"

from sleap_io.model.skeleton import Node, Edge, Skeleton, Symmetry
from sleap_io.model.video import Video
Expand Down
4 changes: 2 additions & 2 deletions sleap_io/io/slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def write_videos(labels_path: str, videos: list[Video]):
)
video_jsons.append(np.string_(json.dumps(video_json, separators=(",", ":"))))

with h5py.File(labels_path, "a") as f:
f.create_dataset("videos_json", data=video_jsons, maxshape=(None,))
with h5py.File(labels_path, "a") as f:
f.create_dataset("videos_json", data=video_jsons, maxshape=(None,))


def read_tracks(labels_path: str) -> list[Track]:
Expand Down
7 changes: 7 additions & 0 deletions tests/io/test_slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ def test_write_videos(slp_minimal_pkg, centered_pair, tmp_path):
json_test = read_hdf5_dataset(tmp_path / "test_centered_pair.slp", "videos_json")
assert json_fixture == json_test

videos = read_videos(centered_pair) * 2
write_videos(tmp_path / "test_centered_pair_2vids.slp", videos)
json_test = read_hdf5_dataset(
tmp_path / "test_centered_pair_2vids.slp", "videos_json"
)
assert len(json_test) == 2


def test_write_tracks(centered_pair, tmp_path):
tracks = read_tracks(centered_pair)
Expand Down