Skip to content
Open
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
3 changes: 3 additions & 0 deletions ethology/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .sample_data import load_sample_tracking

__all__ = ["load_sample_tracking"]
28 changes: 28 additions & 0 deletions ethology/datasets/sample_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Utilities for downloading and loading example datasets for ethology.

This module provides helper functions that use `pooch` to fetch
small example datasets used in tutorials, tests, and documentation.
"""

import pooch

...


DATA_REGISTRY = pooch.create(
path=pooch.os_cache("ethology"),
base_url="https://example-dataset-url/",
registry={"example_tracking.csv": None},
)


def load_sample_tracking() -> str:
"""Fetch a sample tracking dataset.

Returns
-------
str
Path to the downloaded dataset.

"""
return DATA_REGISTRY.fetch("example_tracking.csv")
2 changes: 1 addition & 1 deletion ethology/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
""" Load and export `ethology` datasets."""
"""Load and export `ethology` datasets."""
1 change: 1 addition & 0 deletions examples/approximate_subset_sum_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Split an annotations dataset by grouping variable, and compare to random
splitting.
"""

# %%
# This example demonstrates two dataset splitting strategies:
#
Expand Down
1 change: 0 additions & 1 deletion examples/coco_bbox_ethology_and_movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
`movement <https://movement.neuroinformatics.dev/>`_.
"""


# %%
# Imports
# -------
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies = [
"torch",
"torchvision",
"loguru",
"pooch",
"tables>=3.10.1" # wheels compatible with MacOS ARM
]

Expand Down
26 changes: 26 additions & 0 deletions tests/test_sample_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from ethology.datasets import load_sample_tracking


def test_load_sample_tracking_returns_path():
"""Ensure loader returns a valid file path."""
path = load_sample_tracking()

assert isinstance(path, str)
assert os.path.exists(path)


def test_load_sample_tracking_cached():
"""Ensure dataset is cached and not downloaded twice."""
path1 = load_sample_tracking()
path2 = load_sample_tracking()

assert path1 == path2


def test_sample_dataset_filename():
"""Check returned dataset filename."""
path = load_sample_tracking()

assert path.endswith("example_tracking.csv")
6 changes: 3 additions & 3 deletions tests/test_unit/test_io_annotations/test_load_bboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ def test_df_from_single_file(
expected_n_unique_images_with_annotations,
expected_categories=expected_category_data[0],
expected_supercategories=expected_category_data[1],
expected_annots_per_image=1
if expected_n_unique_images_with_annotations < 5
else None,
expected_annots_per_image=(
1 if expected_n_unique_images_with_annotations < 5 else None
),
)

# Check image shape data is present if present in the input file
Expand Down