Skip to content

Commit

Permalink
Switch to actual median and tidy up lint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineC committed Oct 13, 2023
1 parent 4b67615 commit 9194d6c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 35 deletions.
8 changes: 4 additions & 4 deletions labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def get_average_time_in_labels(
average_time_in_labels = {}
med_time_in_labels = {}
ninety_percentile_in_labels = {}
for label in time_in_labels:
average_time_in_labels[label] = numpy.average(time_in_labels[label])
med_time_in_labels[label] = numpy.median(time_in_labels[label])
ninety_percentile_in_labels[label] = numpy.percentile(time_in_labels[label], 90, axis=0)
for label, time_list in time_in_labels.items():
average_time_in_labels[label] = numpy.average(time_list)
med_time_in_labels[label] = numpy.median(time_list)
ninety_percentile_in_labels[label] = numpy.percentile(time_list, 90, axis=0)

for label in labels:
if label not in average_time_in_labels:
Expand Down
50 changes: 31 additions & 19 deletions markdown_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,31 +184,43 @@ def write_overall_metrics_table(
file.write("| Metric | Average | Median | 90th percentile |\n")
file.write("| --- | --- | --- | ---: |\n")
if "Time to first response" in columns:
if (stats_time_to_first_response != None):
file.write(
f"| Time to first response | {stats_time_to_first_response['avg']} | {stats_time_to_first_response['med']} | {stats_time_to_first_response['90p']} |\n"
)
else:
file.write(f"| Time to first response | None | None | None |\n")
if stats_time_to_first_response is not None:
file.write(
f"| Time to first response "
f"| {stats_time_to_first_response['avg']} "
f"| {stats_time_to_first_response['med']} "
f"| {stats_time_to_first_response['90p']} |\n"
)
else:
file.write("| Time to first response | None | None | None |\n")
if "Time to close" in columns:
if (stats_time_to_close != None):
file.write(
f"| Time to close | {stats_time_to_close['avg']} | {stats_time_to_close['med']} | {stats_time_to_close['90p']} |\n"
)
else:
file.write(f"| Time to close | None | None | None |\n")
if stats_time_to_close is not None:
file.write(
f"| Time to close "
f"| {stats_time_to_close['avg']} "
f"| {stats_time_to_close['med']} "
f"| {stats_time_to_close['90p']} |\n"
)
else:
file.write("| Time to close | None | None | None |\n")
if "Time to answer" in columns:
if (stats_time_to_answer != None):
file.write(
f"| Time to answer | {stats_time_to_answer['avg']} | {stats_time_to_answer['med']} | {stats_time_to_answer['90p']} |\n"
)
else:
file.write(f"| Time to answer | None | None | None |\n")
if stats_time_to_answer is not None:
file.write(
f"| Time to answer "
f"| {stats_time_to_answer['avg']} "
f"| {stats_time_to_answer['med']} "
f"| {stats_time_to_answer['90p']} |\n"
)
else:
file.write("| Time to answer | None | None | None |\n")
if labels and stats_time_in_labels:
for label in labels:
if f"Time spent in {label}" in columns and label in stats_time_in_labels['avg']:
file.write(
f"| Time spent in {label} | {stats_time_in_labels['avg'][label]} | {stats_time_in_labels['med'][label]} | {stats_time_in_labels['90p'][label]} |\n"
f"| Time spent in {label} "
f"| {stats_time_in_labels['avg'][label]} "
f"| {stats_time_in_labels['med'][label]} "
f"| {stats_time_in_labels['90p'][label]} |\n"
)
file.write(f"| Number of items that remain open | {num_issues_opened} |\n")
file.write(f"| Number of items closed | {num_issues_closed} |\n")
Expand Down
27 changes: 15 additions & 12 deletions test_markdown_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class TestWriteToMarkdown(unittest.TestCase):
"""Test the write_to_markdown function."""
maxDiff = None

def test_write_to_markdown(self):
"""Test that write_to_markdown writes the correct markdown file.
Expand Down Expand Up @@ -64,6 +65,7 @@ def test_write_to_markdown(self):
'avg': {"bug": "1 day, 12:00:00"},
'med': {"bug": "1 day, 12:00:00"},
'90p': {"bug": "1 day, 12:00:00"}}

num_issues_opened = 2
num_issues_closed = 1

Expand Down Expand Up @@ -138,21 +140,22 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
),
]
average_time_to_first_response = {
'avg' : timedelta(days=2),
'med' : timedelta(days=2),
'90p' : timedelta(days=2)}
'avg': timedelta(days=2),
'med': timedelta(days=2),
'90p': timedelta(days=2)}
average_time_to_close = {
'avg' : timedelta(days=3),
'med' : timedelta(days=3),
'90p' : timedelta(days=3)}
'avg': timedelta(days=3),
'med': timedelta(days=3),
'90p': timedelta(days=3)}
average_time_to_answer = {
'avg' : timedelta(days=4),
'med' : timedelta(days=4),
'90p' : timedelta(days=4)}
'avg': timedelta(days=4),
'med': timedelta(days=4),
'90p': timedelta(days=4)}
average_time_in_labels = {
'avg' : {"bug": "1 day, 12:00:00"},
'med' : {"bug": "1 day, 12:00:00"},
'90p' : {"bug": "1 day, 12:00:00"}}
'avg': {"bug": "1 day, 12:00:00"},
'med': {"bug": "1 day, 12:00:00"},
'90p': {"bug": "1 day, 12:00:00"}}

num_issues_opened = 2
num_issues_closed = 1

Expand Down

0 comments on commit 9194d6c

Please sign in to comment.