Skip to content

Commit 5afb228

Browse files
Removed excess comments and FIXED the previous plotting bug
1 parent e0f2a08 commit 5afb228

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/analysis/analysis.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ def _save_plot(plot: plt, name: str):
88
plot.savefig(file_path, dpi=300)
99

1010
def _create_size_impact_plot():
11-
# 3. How does the size of a commit impact the results?
12-
1311
# Read data from the repo_data csv
1412
repo_data = file_utils.read_csv("repo_data")
1513

@@ -33,6 +31,9 @@ def _create_size_impact_plot():
3331
x = np.array(x)
3432
y = np.array(y)
3533

34+
# Clear any existing plot
35+
plt.clf()
36+
3637
# Plot the scatter points
3738
plt.scatter(x, y, c=y, cmap = 'winter')
3839

@@ -45,11 +46,10 @@ def _create_size_impact_plot():
4546
plt.xlabel("Repo Size (No. of files)")
4647
plt.ylabel("Percentage of TDD")
4748
plt.title("Repo size and TDD percentage")
49+
4850
_save_plot(plt, "Size Impact")
4951

5052
def _create_box_plot():
51-
# 2. How often is a test class (file) created (a) before, (b) after, or (c) in the same commit as a tested class (file)?
52-
5353
# Read data from the repo_data csv
5454
repo_data = file_utils.read_csv("repo_data")
5555

@@ -69,6 +69,9 @@ def _create_box_plot():
6969
after.append((int(repo['Test After']) / total_test_count) * 100)
7070
during.append((int(repo['Test During']) / total_test_count) * 100)
7171

72+
# Clear any existing plot
73+
plt.clf()
74+
7275
# Plot the box plots
7376
boxplt = plt.boxplot([before, after, during], patch_artist=True, tick_labels=["Before", "After", "During"], flierprops= dict(markerfacecolor='coral'))
7477

@@ -97,6 +100,9 @@ def _create_avg_commit_size_plot():
97100
after_avg = (after_avg + float(repo['Avg After Commit Size'])) / 2
98101
during_avg = (during_avg + float(repo['Avg During Commit Size'])) / 2
99102

103+
# Clear any existing plot
104+
plt.clf()
105+
100106
# Plot the bar chart
101107
colors = ['palegreen', 'lightblue', 'lightskyblue']
102108
plt.bar(["Before", "After", "During"], [before_avg, after_avg, during_avg], align='center', color=colors)
@@ -142,6 +148,9 @@ def _create_pie_plot():
142148
for i in range(len(labels)):
143149
labels[i] = labels[i] + ' - ' + str(round(percentages[i], 0)) + '%'
144150

151+
# Clear any existing plot
152+
plt.clf()
153+
145154
# Set up and plot the pie chart, colors, legend and title
146155
colours = ['#225ea8', '#1d91c0', '#41b6c4', '#7fcdbb', '#c7e9b4', '#71cb71']
147156
plt.rcParams["figure.figsize"] = [7.5, 4.25]
@@ -154,8 +163,8 @@ def _create_pie_plot():
154163

155164

156165
def create_plots():
157-
_create_size_impact_plot()
158166
_create_box_plot()
167+
_create_size_impact_plot()
159168
_create_avg_commit_size_plot()
160169
_create_pie_plot()
161170

0 commit comments

Comments
 (0)