File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -197,14 +197,17 @@ def test_weighted_mode_favors_high_fitness(self):
197197 parent , _ = self .db .sample_from_island (island_id = 0 )
198198 sampled_scores .append (parent .metrics ["score" ])
199199
200- # Average sampled score should be higher than median score of all programs
200+ # Average sampled score should be higher than mean score of all programs
201+ # (mean represents what uniform random sampling would produce)
201202 island_programs = [self .db .programs [pid ] for pid in self .db .islands [0 ]]
202203 all_scores = [p .metrics ["score" ] for p in island_programs ]
203- median_score = sorted (all_scores )[ len (all_scores ) // 2 ]
204+ mean_score = sum (all_scores ) / len (all_scores )
204205 avg_sampled_score = sum (sampled_scores ) / len (sampled_scores )
205206
206- # Weighted sampling should favor higher scores
207- self .assertGreater (avg_sampled_score , median_score )
207+ # Weighted sampling should favor higher scores (shift average upward from mean)
208+ self .assertGreater (avg_sampled_score , mean_score ,
209+ f"Weighted sampling should favor high fitness: "
210+ f"sampled_avg={ avg_sampled_score :.4f} should be > mean={ mean_score :.4f} " )
208211
209212
210213class TestSampleFromIslandEdgeCases (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments