You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
from services import log_services |
|
|
|
def tally_readings_per_second(data): |
|
time_tallies = dict() |
|
for item in data: |
|
key = item[0] |
|
if (key in time_tallies): |
|
time_tallies[key] = time_tallies[key] + 1 |
|
else: |
|
time_tallies[key] = 1 |
|
return time_tallies |
|
|
|
def total_count_for_each_reading_per_second(time_tallies): |
|
tally_totals = dict() |
|
for val in time_tallies.values(): |
|
if (val in tally_totals): |
|
tally_totals[val] = (tally_totals[val]) + 1 |
|
else: |
|
tally_totals[val] = 1 |
|
return tally_totals |
|
|
|
def get_rps_above(threshold, readings): |
|
times = list() |
|
# print(readings.values()) |
|
for k, v in readings.items(): |
|
# print([k, v]) |
|
if (v >= threshold): |
|
times.append(k) |
|
return times |
|
|
|
def tally_flickers(selected_readings, all_readings): |
|
selected = dict() |
|
log_services.print_list(selected_readings) |
|
# for time in selected_readings: |
|
|
|
# for time in selected_readings: |
|
# # print(f"Looking for {time}...") |
|
# selected[time] = all_readings[time] |
|
# # for k, v in all_readings.items(): |
|
return selected
|
|
|