@@ -82,7 +82,7 @@ def create_avg_commit_size_plot():
8282 # Read data from the repo_data csv
8383 repo_data = read_csv ("repo_data" )
8484
85- # Initialize arrays to store percentages for each repo
85+ # Initialize variables to store averages for each repo
8686 before_avg = 0
8787 during_avg = 0
8888 after_avg = 0
@@ -93,12 +93,52 @@ def create_avg_commit_size_plot():
9393 during_avg = (during_avg + float (repo ['Avg During Commit Size' ])) / 2
9494 after_avg = (after_avg + float (repo ['Avg After Commit Size' ])) / 2
9595
96+ # Plot the bar chart
9697 plt .bar (["Before" , "During" , "After" ], [before_avg , during_avg , after_avg ], align = 'center' )
98+ # Show the plot
99+ plt .show ()
100+
101+
102+ def create_pie_plot ():
103+ # Read data from the author_data csv
104+ author_data = read_csv ("author_data" )
105+
106+ # Initialize Counters
107+ labels = ['Non TDD' , 'Rarely TDD' , 'Occasionally TDD' , 'Somewhat TDD' , 'Mostly TDD' , 'Consistently TDD' ]
108+ # 10 25 50 70 90 100
109+ counters = [0 ,0 ,0 ,0 ,0 ,0 ]
110+
111+
112+ for author in author_data :
113+ # Calculate the percentage of TDD of the author
114+ TDD_percent = (float (author ['Test Before' ]) / (float (author ['Test Before' ]) + float (author ['Test During' ]) + float (author ['Test After' ]))) * 100
115+
116+ # Update the counters array based on this result
117+ if TDD_percent < 10 :
118+ counters [0 ] += 1
119+ elif TDD_percent < 25 :
120+ counters [1 ] += 1
121+ elif TDD_percent < 50 :
122+ counters [2 ] += 1
123+ elif TDD_percent < 70 :
124+ counters [3 ] += 1
125+ elif TDD_percent < 90 :
126+ counters [4 ] += 1
127+ elif TDD_percent < 100 :
128+ counters [5 ] += 1
129+
130+ # Convert the counters into percentages using a lambda function and map
131+ percentages = list (map (lambda x : x / len (author_data )* 100 , counters ))
132+
133+ # Plot the pie chart
134+ plt .pie (percentages , labels = labels )
135+ # Show the plot
97136 plt .show ()
98137
99138#create_size_impact_plot()
100139#create_box_plot()
101- create_avg_commit_size_plot ()
140+ #create_avg_commit_size_plot()
141+ create_pie_plot ()
102142
103143'''
104144
0 commit comments