Skip to content

Commit 5e2d645

Browse files
committed
Update test_sample_from_island_ratios.py
1 parent 3edfef1 commit 5e2d645

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_sample_from_island_ratios.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff 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

210213
class TestSampleFromIslandEdgeCases(unittest.TestCase):

0 commit comments

Comments
 (0)