Skip to content

Commit

Permalink
Fix negative battery consumption rate bug (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferfedor authored Aug 9, 2023
1 parent bd94d17 commit 4adeca8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/change-log.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Change Log

## v1.10.0
## v1.9.4

- Fix bug in PHONE_BATTERY RAPIDS provider that could result in negative values for battery consumption rate features
- Fix bug in PHONE_APPLICATIONS_FOREGROUND RAPIDS provider that could result in some rows being excluded from output depending on order in which apps are processed
- Fix bug in PHONE_SCREEN RAPIDS provider that dropped rows exceeding specified thresholds based on within-segment rather than overall episode duration
- Add mutation script to fix character encoding of bt_name column in phone Bluetooth data
- Add mutation script to fix character encoding of package_name, before_text, and current_text columns in phone keyboard data
- Update documentation for Docker and Ubuntu installation
- Specify that R version 4.2.3 be installed in tests workflow and Dockerfile
- Update documentation for Docker, Mac and Ubuntu installation

## v1.9.3

Expand Down
9 changes: 7 additions & 2 deletions src/features/phone_battery/rapids/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_se

if not battery_data.empty:

battery_data["episode_id"] = ((battery_data.battery_status != battery_data.battery_status.shift()) | (battery_data.start_timestamp - battery_data.end_timestamp.shift() > 1)).cumsum()
battery_data["episode_id"] = (
(battery_data.battery_status != battery_data.battery_status.shift()) |
(battery_data.start_timestamp - battery_data.end_timestamp.shift() > 1) |
((battery_data.battery_status.isin([3, 4])) & (battery_data.battery_level > battery_data.battery_level.shift()))
).cumsum()

grouped = battery_data.groupby(by=["local_segment", "episode_id", "battery_status"])
battery_episodes= grouped[["duration"]].sum()
battery_episodes = grouped[["duration"]].sum()
battery_episodes["battery_diff"] = grouped["battery_level"].first() - grouped["battery_level"].last()
battery_episodes["battery_consumption_rate"] = battery_episodes["battery_diff"] / battery_episodes["duration"]
battery_episodes.reset_index(inplace=True)
Expand Down

0 comments on commit 4adeca8

Please sign in to comment.