Skip to content

Commit ae363a9

Browse files
FIXED - average code on line 97 is completely wrong because of the 0
1 parent ec63f88 commit ae363a9

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/analysis/analysis.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,32 @@ def _create_avg_commit_size_plot():
9494
# Read data from the repo_data csv
9595
repo_data = file_utils.read_csv("repo_data")
9696

97-
# Initialize variables to store averages for each repo
98-
before_avg = 0
99-
after_avg = 0
100-
during_avg = 0
97+
# Initialize variables to store total for each repo
98+
before_total = 0
99+
after_total = 0
100+
during_total = 0
101101

102-
# Iterate through each repo and update the before, during and after averages
102+
# Iterate through each repo and update the before, during and after totals
103103
for repo in repo_data:
104-
before_avg = (before_avg + float(repo['Avg Before Commit Size'])) / 2
105-
after_avg = (after_avg + float(repo['Avg After Commit Size'])) / 2
106-
during_avg = (during_avg + float(repo['Avg During Commit Size'])) / 2
104+
before_total += float(repo['Avg Before Commit Size'])
105+
after_total += float(repo['Avg After Commit Size'])
106+
during_total += float(repo['Avg During Commit Size'])
107+
108+
# Calculate the average commit size using the totals above
109+
before_avg = before_total / len(repo_data)
110+
after_avg = after_total / len(repo_data)
111+
during_avg = during_total / len(repo_data)
107112

108113
# Clear any existing plot
109114
plt.clf()
110115

111116
# Plot the bar chart
112117
colors = ['palegreen', 'lightblue', 'lightskyblue']
113118
plt.bar(["Before", "After", "During"], [before_avg, after_avg, during_avg], align='center', color=colors)
114-
plt.bar(["Before", "After", "During"], [before_avg, after_avg, during_avg], align='center', color=colors)
119+
120+
# Place values at the top of each bar
121+
for index, value in enumerate([before_avg, after_avg, during_avg]):
122+
plt.text(index, value+0.5, round(value, 1), ha='center')
115123

116124
# Set title and axes labels
117125
plt.ylabel("Average Commit Size (No. of files)")
@@ -226,6 +234,7 @@ def create_plots():
226234
_create_pie_plot_tdd_levels()
227235
_create_pie_plot_tdd_overall()
228236

237+
# REMEMBER TO REMOVE THESE
229238
create_plots()
230239

231240
'''
@@ -235,7 +244,6 @@ def create_plots():
235244
todo -
236245
plot like the TDD cagetories pie, but for repo instead of author - modify _create_pie_plot_tdd_levels
237246
bar chart for tdd percentace per langange - ignoring during
238-
average code on line 97 is completely wrong because of the 0
239247
overall tdd percentage - pie of before and after, excluding during
240248
241249
'''

0 commit comments

Comments
 (0)