Coverage for tests / test_balance_tests_sway.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-12 11:20 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-12 11:20 +0000
1import os
2import pytest
3from datetime import datetime
5from numpy import arange, zeros
6from pandas import read_csv
7from physiodsp.sensors.imu.accelerometer import AccelerometerData
8from physiodsp.balance_tests.sway import Sway
10test_folder_path = os.path.dirname(os.path.realpath(__file__))
13@pytest.mark.parametrize(
14 "fs",
15 [
16 (25),
17 ]
18)
19def test_balance_test_sway(fs):
21 df = read_csv(os.path.join(test_folder_path, "sway.csv"), usecols=["x", "z"])
22 n_samples = len(df)
24 timestamp_start = datetime.now().timestamp()
25 timestamps = timestamp_start + arange(start=0, step=1/fs, stop=int(n_samples/fs))
27 accelerometer = AccelerometerData(
28 timestamps=timestamps,
29 x=df.x.values[:len(timestamps)],
30 y=zeros(len(timestamps)),
31 z=df.z.values[:len(timestamps)],
32 fs=fs
33 )
35 processor = Sway().run(accelerometer=accelerometer, sensor_height=1.4)
37 metrics = processor.biomarker
39 assert metrics is not None
40 assert hasattr(metrics, "shape")
41 assert hasattr(metrics, "columns")
42 assert hasattr(metrics, "empty")
43 assert not metrics.empty
44 assert metrics.shape[0] == 3