@@ -7,6 +7,22 @@ def _save_plot(plot: plt, name: str):
77    file_path  =  os .path .join (file_utils .CHARTS_PATH , f"{ name }  .jpg" )
88    plot .savefig (file_path )
99
10+ 
11+ def  _get_category_index (tdd_percentage ):
12+     # Return which index to increment - 10 25 50 70 90 100 
13+     if  tdd_percentage  <  10 :
14+         return  0 
15+     elif  tdd_percentage  <  25 :
16+         return  1 
17+     elif  tdd_percentage  <  50 :
18+         return  2 
19+     elif  tdd_percentage  <  70 :
20+         return  3 
21+     elif  tdd_percentage  <  90 :
22+         return  4 
23+     elif  tdd_percentage  <=  100 :
24+         return  5 
25+ 
1026def  _create_size_impact_plot ():
1127    # Read data from the repo_data csv 
1228    repo_data  =  file_utils .read_csv ("repo_data" )
@@ -139,21 +155,10 @@ def _create_pie_plot_tdd_author_categories():
139155    for  author  in  author_data :
140156        # Calculate the percentage of TDD of the author 
141157        # we don't count test_during as we want TDD percentage, not before, during and after percentage 
142-         TDD_percent  =  (float (author ['Test Before' ]) /  max (1 , float (author ['Test Before' ]) +  float (author ['Test After' ]))) *  100 
158+         tdd_percentage  =  (float (author ['Test Before' ]) /  max (1 , float (author ['Test Before' ]) +  float (author ['Test After' ]))) *  100 
143159
144160        # Update the counters array based on this result 
145-         if  TDD_percent  <  10 :
146-             counters [0 ] +=  1 
147-         elif  TDD_percent  <  25 :
148-             counters [1 ] +=  1 
149-         elif  TDD_percent  <  50 :
150-             counters [2 ] +=  1 
151-         elif  TDD_percent  <  70 :
152-             counters [3 ] +=  1 
153-         elif  TDD_percent  <  90 :
154-             counters [4 ] +=  1 
155-         elif  TDD_percent  <=  100 :
156-             counters [5 ] +=  1 
161+         counters [_get_category_index (tdd_percentage )] +=  1 
157162
158163    # Convert the counters into percentages using a lambda function and map 
159164    percentages  =  list (map (lambda  x : x / max (1 , len (author_data ))* 100 , counters ))
@@ -277,21 +282,10 @@ def _create_pie_plot_tdd_repo_categories():
277282    for  repo  in  repo_data :
278283        # Calculate the percentage of TDD of the author 
279284        # we don't count test_during as we want TDD percentage, not before, during and after percentage 
280-         TDD_percent  =  (float (repo ['Test Before' ]) /  max (1 , float (repo ['Test Before' ]) +  float (repo ['Test After' ]))) *  100 
285+         tdd_percentage  =  (float (repo ['Test Before' ]) /  max (1 , float (repo ['Test Before' ]) +  float (repo ['Test After' ]))) *  100 
281286
282287        # Update the counters array based on this result 
283-         if  TDD_percent  <  10 :
284-             counters [0 ] +=  1 
285-         elif  TDD_percent  <  25 :
286-             counters [1 ] +=  1 
287-         elif  TDD_percent  <  50 :
288-             counters [2 ] +=  1 
289-         elif  TDD_percent  <  70 :
290-             counters [3 ] +=  1 
291-         elif  TDD_percent  <  90 :
292-             counters [4 ] +=  1 
293-         elif  TDD_percent  <=  100 :
294-             counters [5 ] +=  1 
288+         counters [_get_category_index (tdd_percentage )] +=  1 
295289
296290    # Convert the counters into percentages using a lambda function and map 
297291    percentages  =  list (map (lambda  x : x / max (1 , len (repo_data ))* 100 , counters ))
0 commit comments