Skip to content

Commit ed0a951

Browse files
committed
Add constants to sleep_utils instead of magic numbers
1 parent 7342d83 commit ed0a951

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/actinet/utils/sleep_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import numpy as np
22
import pandas as pd
33

4+
SLEEP_GAP_TOLERANCE = 30 * 60 # 30 minutes
5+
SLEEP_BLOCK_PERIOD = 24 * 60 * 60 # 24 hours
6+
47

58
def removeSpuriousSleep(Y, labels, period, sleepTol='1H', removeNaps=False):
69
"""
@@ -77,11 +80,11 @@ def convertNaps(Y, period, sleep_code, sedentary_code):
7780
:rtype: numpy.ndarray
7881
"""
7982

80-
sleep_blocks = find_blocks(Y, gap_tol=int(1800/period), # 30 minute gap tolerance
83+
sleep_blocks = find_blocks(Y, gap_tol=int(SLEEP_GAP_TOLERANCE/period),
8184
block_code=sleep_code)
8285

8386
longest_blocks = select_longest_blocks_per_period(
84-
sleep_blocks, len(Y), block_period=int(86400/period) # 24 hours sleep block period
87+
sleep_blocks, len(Y), block_period=int(SLEEP_BLOCK_PERIOD/period)
8588
)
8689

8790
return convert_non_selected_block(Y, longest_blocks, sleep_code, sedentary_code)

0 commit comments

Comments
 (0)