@@ -8,25 +8,43 @@ def get_obj_percentage_data(df):
8
8
gen_data = []
9
9
for generation in range (3 ):
10
10
vals = df [df ["generation_number" ] == generation ]
11
- gen_data .append ((vals ["collected_cycles" ] / vals ["total_objects" ]).values )
11
+ item = vals ["collected_cycles" ] / vals ["total_objects" ].values
12
+ if item .size == 0 :
13
+ item = np .array ([0 ])
14
+ gen_data .append (item )
12
15
return gen_data
13
16
14
17
15
18
def get_gen_time_data (df ):
16
19
gen_data = []
17
20
for generation in range (3 ):
18
21
vals = df [df ["generation_number" ] == generation ]
19
- gen_data .append (vals ["collection_time" ])
22
+ item = vals ["collection_time" ].values
23
+ if item .size == 0 :
24
+ item = np .array ([0 ])
25
+ gen_data .append (item )
20
26
return gen_data
21
27
22
28
23
29
def get_gen_time_data_per_obj (df ):
24
30
gen_data = []
25
31
for generation in range (3 ):
26
32
vals = df [df ["generation_number" ] == generation ]
27
- gen_data .append (vals ["collection_time" ] / vals ["total_objects" ])
33
+ item = vals ["collection_time" ] / vals ["total_objects" ].values
34
+ if item .size == 0 :
35
+ item = np .array ([0 ])
36
+ gen_data .append (item )
28
37
return gen_data
29
38
39
+ def get_gen_freq_per_us (df ):
40
+ gen_data = []
41
+ for generation in range (3 ):
42
+ vals = df [df ["generation_number" ] == generation ]
43
+ item = 1.0 / (vals ["collection_time" ] / vals ["total_objects" ]).values / 1.0e6
44
+ if item .size == 0 :
45
+ item = np .array ([0 ])
46
+ gen_data .append (item )
47
+ return gen_data
30
48
31
49
def gen_plot (df , output_filename ):
32
50
def violinplot_with_custom_formatting (
@@ -49,8 +67,8 @@ def violinplot_with_custom_formatting(
49
67
ax .set_title (title )
50
68
51
69
names = ["First generation" , "Second generation" , "Third generation" ]
52
- fig , (ax1 , ax2 , ax3 ) = plt .subplots (
53
- 3 , 1 , figsize = (8 , (2 + len (names ) * 0.3 ) * 3 ), layout = "constrained"
70
+ fig , (ax1 , ax2 , ax3 , ax4 ) = plt .subplots (
71
+ 4 , 1 , figsize = (8 , (2 + len (names ) * 0.3 ) * 4 ), layout = "constrained"
54
72
)
55
73
56
74
obj_percentage_data = get_obj_percentage_data (df )
@@ -89,6 +107,18 @@ def violinplot_with_custom_formatting(
89
107
formatter = formatter ,
90
108
)
91
109
110
+ formatter = lambda val , pos : f"{ int (val )} obj/us"
111
+ gen_freq_per_us = get_gen_freq_per_us (df )
112
+ violinplot_with_custom_formatting (
113
+ ax4 ,
114
+ gen_freq_per_us ,
115
+ names ,
116
+ (0 , len (names ) + 1 ),
117
+ "time" ,
118
+ "Objects collected per us stats" ,
119
+ formatter = formatter ,
120
+ )
121
+
92
122
plt .savefig (output_filename )
93
123
plt .close ()
94
124
0 commit comments