Skip to content

Commit 0691ffa

Browse files
authored
Update fitbit sense synthetic and improve error printing (#182)
1 parent 251526f commit 0691ffa

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

wearipedia/devices/fitbit/fitbit_sense.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def _gen_synthetic(self):
145145
self.minutesVeryActive = syn_data["minutesVeryActive"]
146146
self.minutesFairlyActive = syn_data["minutesFairlyActive"]
147147
self.minutesLightlyActive = syn_data["minutesLightlyActive"]
148-
self.distance = syn_data["distance"]
149148
self.minutesSedentary = syn_data["minutesSedentary"]
150-
self.heart_rate_day = syn_data["heart_rate"]
149+
self.distance = syn_data["distance"]
150+
self.heart_rate_day = syn_data["heart_rate_day"]
151151
self.hrv = syn_data["hrv"]
152152
self.distance_day = syn_data["distance_day"]
153153
self.intraday_breath_rate = syn_data["intraday_breath_rate"]

wearipedia/devices/fitbit/fitbit_sense_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def call_API(url: str, access_token: str, call: str = "GET"):
1414
try:
1515
error_detail = response.json()
1616
if isinstance(error_detail, dict):
17-
error_msg = f"{error_msg} - {error_detail.get('detail', '')}"
17+
error_msg = f"{error_msg} - {error_detail}"
1818
except:
1919
pass
2020

wearipedia/devices/fitbit/fitbit_sense_gen.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,14 @@ def get_distance_day(date):
527527

528528

529529
def create_syn_data(seed, start_date, end_date):
530-
"""Returns a defaultdict of heart_rate data, activity data, "sleep", "steps","minutesVeryActive", "minutesLightlyActive", "minutesFairlyActive", "distance", "minutesSedentary", "heart_rate_day", "hrv", "distance_day"
530+
"""Returns a dict of heart_rate data, activity data, "sleep", "steps","minutesVeryActive", "minutesLightlyActive", "minutesFairlyActive", "distance", "minutesSedentary", "heart_rate_day", "hrv", "distance_day"
531531
532532
:param start_date: the start date (inclusive) as a string in the format "YYYY-MM-DD"
533533
:type start_date: str
534534
:param end_date: the end date (inclusive) as a string in the format "YYYY-MM-DD"
535535
:type end_date: str
536-
:return: a defaultdict of heart_rate data, activity data, "sleep", "steps","minutesVeryActive", "minutesLightlyActive", "minutesFairlyActive", "distance", "minutesSedentary", "heart_rate_day", "hrv", "distance_day"
537-
:rtype: defaultdict
536+
:return: a dict of heart_rate data, activity data, "sleep", "steps","minutesVeryActive", "minutesLightlyActive", "minutesFairlyActive", "distance", "minutesSedentary", "heart_rate_day", "hrv", "distance_day"
537+
:rtype: dict
538538
"""
539539

540540
random.seed(seed)
@@ -552,7 +552,23 @@ def create_syn_data(seed, start_date, end_date):
552552
for i in range(num_days)
553553
]
554554

555-
full_dict = collections.defaultdict(list)
555+
full_dict = {}
556+
full_dict["sleep"] = []
557+
full_dict["steps"] = []
558+
full_dict["minutesVeryActive"] = []
559+
full_dict["minutesFairlyActive"] = []
560+
full_dict["minutesLightlyActive"] = []
561+
full_dict["minutesSedentary"] = []
562+
full_dict["distance"] = []
563+
full_dict["heart_rate_day"] = []
564+
full_dict["hrv"] = []
565+
full_dict["distance_day"] = []
566+
full_dict["intraday_breath_rate"] = []
567+
full_dict["intraday_active_zone_minute"] = []
568+
full_dict["intraday_activity"] = []
569+
full_dict["intraday_heart_rate"] = []
570+
full_dict["intraday_hrv"] = []
571+
full_dict["intraday_spo2"] = []
556572

557573
for date in synth_dates:
558574
(
@@ -564,6 +580,7 @@ def create_syn_data(seed, start_date, end_date):
564580

565581
activity = get_activity(date)
566582

583+
hr = get_heart_rate(date, intraday=False)
567584
intraday_hr = get_heart_rate(date, intraday=True)
568585

569586
# Collect all data points
@@ -579,6 +596,19 @@ def create_syn_data(seed, start_date, end_date):
579596
full_dict["hrv"].append(get_hrv(date))
580597

581598
full_dict["distance_day"].append(get_distance_day(date))
599+
full_dict["intraday_breath_rate"].append(get_intraday_breath_rate(date))
600+
full_dict["intraday_active_zone_minute"].append(
601+
get_intraday_azm(date, intraday_hr)
602+
)
603+
full_dict["intraday_heart_rate"].append(intraday_hr)
604+
full_dict["intraday_hrv"].append(
605+
get_intraday_hrv(date, random_hour, random_min, random_sec, random_duration)
606+
)
607+
full_dict["intraday_spo2"].append(
608+
get_intraday_spo2(
609+
date, random_hour, random_min, random_sec, random_duration
610+
)
611+
)
582612

583613
# encapsulate to match original data shape
584614
data = []

0 commit comments

Comments
 (0)