Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes PerformanceWarning in detect_non_wear_time_syed2021 #34

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions paat/wear_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
return episodes.T

# create a new dataframe that will contain the grouped rows
grouped_episodes = pd.DataFrame()
grouped_episodes = []

Check warning on line 248 in paat/wear_time.py

View check run for this annotation

Codecov / codecov/patch

paat/wear_time.py#L248

Added line #L248 was not covered by tests

# get all current values from the first row
current_start = episodes.iloc[0]['start']
Expand Down Expand Up @@ -280,24 +280,28 @@
counter_label = f'{current_counter}-{next_counter}'

# save to new dataframe
grouped_episodes[counter_label] = pd.Series({'counter': counter_label,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label})
grouped_episodes += [pd.Series({

Check warning on line 283 in paat/wear_time.py

View check run for this annotation

Codecov / codecov/patch

paat/wear_time.py#L283

Added line #L283 was not covered by tests
'counter': counter_label,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label
})]
else:

# create the counter label
counter_label = current_counter if (next_counter - current_counter == 1) else f'{current_counter}-{next_counter - 1}'

# save to new dataframe
grouped_episodes[counter_label] = pd.Series({'counter': counter_label,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label})
grouped_episodes += [pd.Series({

Check warning on line 297 in paat/wear_time.py

View check run for this annotation

Codecov / codecov/patch

paat/wear_time.py#L297

Added line #L297 was not covered by tests
'counter': counter_label,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label
})]

# update tracker variables
current_start = next_start
Expand All @@ -311,14 +315,16 @@
if next_counter == episodes.iloc[-1]['counter']:

# save to new dataframe
grouped_episodes[next_counter] = pd.Series({'counter': next_counter,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label})

return grouped_episodes
grouped_episodes += [pd.Series({

Check warning on line 318 in paat/wear_time.py

View check run for this annotation

Codecov / codecov/patch

paat/wear_time.py#L318

Added line #L318 was not covered by tests
'counter': next_counter,
'start_index': current_start_index,
'start': current_start,
'stop_index': current_stop_index,
'stop': current_stop,
'label': None if not training else current_label
})]

return pd.concat(grouped_episodes, axis=1)

Check warning on line 327 in paat/wear_time.py

View check run for this annotation

Codecov / codecov/patch

paat/wear_time.py#L327

Added line #L327 was not covered by tests


def detect_non_wear_time_syed2021(data, sample_freq, cnn_model_file=None, std_threshold=0.004, distance_in_min=5, episode_window_sec=7, edge_true_or_false=True,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "paat"
version = "1.0.0b6"
version = "1.0.0b7"
description = "A comprehensive toolbox to analyse and model raw physical activity data"

license = "MIT"
Expand Down
Loading