Skip to content

Commit

Permalink
adding docstring in test sleep readers, error handling for missing ac…
Browse files Browse the repository at this point in the history
…tigraphy files in sleep readers
  • Loading branch information
simon-p-2000 committed Feb 12, 2025
1 parent b1596c3 commit fcf6260
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sleepecg/io/sleep_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import csv
import datetime
import os
from collections.abc import Iterator
from dataclasses import dataclass
from enum import IntEnum
Expand Down Expand Up @@ -444,6 +445,9 @@ def read_mesa(

activity_data = []

if not os.path.exists(activity_filepath):
print(f"Skipping {record_id} due to missing activity data.")

with open(activity_filepath) as csv_file:
reader = csv.reader(csv_file, delimiter=",")
header = next(reader)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sleep_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _dummy_nsrr_overlap(filename: str, mesa_ids: list[int]):


def _dummy_nsrr_actigraphy(filename: str, mesa_id: str):
"""Create dummy actigraphy file with four usable activity counts."""
base_time = datetime.datetime(2024, 1, 1, 20, 30, 0)

linetimes = [
Expand All @@ -39,6 +40,7 @@ def _dummy_nsrr_actigraphy(filename: str, mesa_id: str):


def _dummy_nsrr_actigraphy_cached(filename: str):
"""Create dummy npy file that resembles cached activity counts."""
activity_counts = np.array([10, 10, 10, 10, 10, 10])
np.save(filename, activity_counts)

Expand Down

0 comments on commit fcf6260

Please sign in to comment.