Skip to content

Commit

Permalink
Merge pull request #91 from AartGoossens/feature/fix_duplicate_fields
Browse files Browse the repository at this point in the history
Added fix for duplicate fields in lap and session summaries
  • Loading branch information
AartGoossens authored Nov 11, 2021
2 parents 7ec400e + 8cc1973 commit 09abcf2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt update
RUN apt install -y software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt update --fix-missing
RUN apt install -y \
RUN apt install --fix-missing -y \
curl \
python3.6-dev \
python3.7-dev \
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Types of changes:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [unreleased] - {date}
### Fixed
- Some FIT files contain records with duplicate field names of which only 1 was not null. Added code to make sure that the non null value was picked.

## [0.23.0] - 2021-11-01
### Changed
- Updated dependency versions. Most notable is scikit-learn to ">= 0.23.1".
Expand Down
12 changes: 10 additions & 2 deletions sweat/io/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ def read_fit(
elif mesg_type == "activity":
activity_summary = record.get_values()
elif mesg_type == "lap":
lap_summaries.append(record.get_values())
lap_summary = {}
for field in record.fields:
if lap_summary.get(field.name, None) is None:
lap_summary[field.name] = field.value
lap_summaries.append(lap_summary)
elif mesg_type == "event":
if record.get_value("event_type") == "start":
# This happens whens an activity is (manually or automatically) paused or stopped and the resumed
Expand All @@ -170,7 +174,11 @@ def read_fit(
# @TODO Decide wether to use these
continue
elif mesg_type == "session":
session_summaries.append(record.get_values())
session_summary = {}
for field in record.fields:
if session_summary.get(field.name, None) is None:
session_summary[field.name] = field.value
session_summaries.append(session_summary)
elif mesg_type == "length":
if pool_lengths:
pool_length_records.append(record.get_values())
Expand Down

0 comments on commit 09abcf2

Please sign in to comment.