Skip to content

Commit

Permalink
String length linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bazilinskyy committed Jan 1, 2025
1 parent 0f8e54b commit 5fb4e89
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions trust/analysis/heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,33 +599,26 @@ def process_kp(self, filter_length=True):
continue
# check if data is string to filter out nan data
if type(row) is list:
# saving amount of times the video has been
# watched
# saving amount of times the video has been watched
counter_data = counter_data + 1
# if list contains only one value, append to
# rt_data
# if list contains only one value, append to rt_data
if len(row) == 1:
rt_data.append(row[0])
# if list contains more then one value, go
# through list to remove keyholds
# if list contains more then one value, go through list to remove keyholds
elif len(row) > 1:
for j in range(1, len(row)):
# if time between 2 stimuli is more
# than 35 ms, add to array (no hold)
# if time between 2 stimuli is more than 35 ms, add to array (no hold)
if row[j] - row[j - 1] > 35:
# append buttonpress data to rt
# array
# append buttonpress data to rt array
rt_data.append(row[j])
# if all data for one video was found, divide them in
# bins
# if all data for one video was found, divide them in bins
kp = []
# loop over all bins, dependent on resolution
for rt in range(self.res, video_len + self.res,
self.res):
bin_counter = 0
for data in rt_data:
# go through all video data to find all data
# within specific bin
# go through all video data to find all data within specific bin
if rt - self.res < data <= rt:
# if data is found, up bin counter
bin_counter = bin_counter + 1
Expand All @@ -642,15 +635,13 @@ def process_kp(self, filter_length=True):
# append data from one video to the mapping array
mapping_rt.append(kp_mean)
if filter_length:
logger.info('Filtered out keypress data from {} videos with '
+ 'unexpected length.', counter_filtered)
logger.info('Filtered out keypress data from {} videos with unexpected length.', counter_filtered)
# update own mapping to include keypress data
self.mapping['kp'] = mapping_rt
# save to csv
if self.save_csv:
# save to csv
self.mapping.to_csv(os.path.join(tr.settings.output_dir,
self.file_mapping_csv))
self.mapping.to_csv(os.path.join(tr.settings.output_dir, self.file_mapping_csv))
# return new mapping
return self.mapping

Expand Down

0 comments on commit 5fb4e89

Please sign in to comment.