Skip to content

Commit

Permalink
v0.0.23: Removed lap/bout inferences. Too slow.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-schroeder committed Jun 30, 2021
1 parent fd8a291 commit e02a091
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
7 changes: 4 additions & 3 deletions docs/source/whatsnew/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Release notes
*************

This is the list of changes to pandas-xyz between each release. For full details,
This is the list of changes to heartandsole between each release. For full details,
see the `commit logs <https://github.com/aaron-schroeder/heartandsole/commits/>`_.

Version 0.0
Expand All @@ -13,6 +13,7 @@ Version 0.0
.. toctree::
:maxdepth: 2

v0.0.20
v0.0.23
v0.0.22
v0.0.21
v0.0.22
v0.0.20
14 changes: 14 additions & 0 deletions docs/source/whatsnew/v0.0.23.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _whatsnew_0023:

What's new in 0.0.23 (June 30, 2021)
------------------------------------

.. _whatsnew_0023.bug_fixes:

Bug fixes
~~~~~~~~~

- Removed lap/bout inference from :meth:`Activity.from_fit` because it
made file read-in take forever. Will reconsider the approach in the
future.

2 changes: 1 addition & 1 deletion heartandsole/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import heartandsole.api
from heartandsole.util import time_from_timestring, timestring_from_time

__version__ = '0.0.22'
__version__ = '0.0.23'
# __all__ = [
# 'Activity',
# ]
58 changes: 30 additions & 28 deletions heartandsole/core/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,32 +351,35 @@ def _build_dataframe_from_msg(msg_type):

# ------------------------------------------------------------------
# Add 'bout' and 'lap' columns to record DF.
# TODO: Figure out how to make this not take so long. It ruins the
# read-in process for large files. In general, I'll leave off the
# lap/bout feature for all files for now.

# If the record timestamp straddles two laps, put it into the
# earlier lap.
activity.records['lap'] = [
activity.laps.index[
activity.timestamp.laps['start'].le(timestamp_rec)
& activity.timestamp.laps['end'].ge(timestamp_rec)
# laps[f'{TIMESTAMP}_start'].le(timestamp_rec)
# & laps[f'{TIMESTAMP}_end'].ge(timestamp_rec)
][0]
for timestamp_rec in activity.timestamp.stream
]

events = _build_dataframe_from_msg('event')
start_events = events[events['event_type'] == 'start'].reset_index()
pause_events = events[events['event_type'] == 'stop_all'].reset_index()

# If the record timestamp straddles two bouts, put it into the
# earlier bout. (That should be impossible, but JIC)
activity.records['bout'] = [
start_events.index[
start_events['timestamp'].le(timestamp_rec)
& pause_events['timestamp'].ge(timestamp_rec)
][0]
for timestamp_rec in activity.timestamp.stream
]
# activity.records['lap'] = [
# activity.laps.index[
# activity.timestamp.laps['start'].le(timestamp_rec)
# & activity.timestamp.laps['end'].ge(timestamp_rec)
# # laps[f'{TIMESTAMP}_start'].le(timestamp_rec)
# # & laps[f'{TIMESTAMP}_end'].ge(timestamp_rec)
# ][0]
# for timestamp_rec in activity.timestamp.stream
# ]

# events = _build_dataframe_from_msg('event')
# start_events = events[events['event_type'] == 'start'].reset_index()
# pause_events = events[events['event_type'] == 'stop_all'].reset_index()

# # If the record timestamp straddles two bouts, put it into the
# # earlier bout. (That should be impossible, but JIC)
# activity.records['bout'] = [
# start_events.index[
# start_events['timestamp'].le(timestamp_rec)
# & pause_events['timestamp'].ge(timestamp_rec)
# ][0]
# for timestamp_rec in activity.timestamp.stream
# ]

# ------------------------------------------------------------------

Expand Down Expand Up @@ -467,11 +470,10 @@ def from_tcx(cls, file_obj):
for tp in reader.trackpoints
])

# This gives us the RECORDED time during a lap - subtracts paused
# time. At least allows me to identify laps that contain pauses.
records['lap'] = [
i for i, l in enumerate(reader.laps) for t in l.trackpoints
]
# TODO: Rethink how I want to use this lap column.
# records['lap'] = [
# i for i, l in enumerate(reader.laps) for t in l.trackpoints
# ]

# Make the lap column into an additional index level.
# TODO: Consider if 'time' or 'timestamp' might make a good
Expand Down

0 comments on commit e02a091

Please sign in to comment.