Skip to content

Commit

Permalink
Fix multi-video serialization in SLP (#72)
Browse files Browse the repository at this point in the history
* Fix and test

* Try to fix opencv

* Use latest CI runners

* Bump version
  • Loading branch information
talmo authored Jan 11, 2024
1 parent 9a04f7f commit f4b50d8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
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

0 comments on commit f4b50d8

Please sign in to comment.