def property_filter_half(cur_index: int, all: t.List[Program], property_func: t.Callable[[Program], float],
remove_upper_half: bool) -> bool:
"""
Note: if the number of programs is uneven, then one program will belong to the upper and the lower half.
"""
vals = [property_func(p) for p in all]
cur_val = vals[cur_index]
median = sp.median(vals)
if (remove_upper_half and cur_val > median) or (not remove_upper_half and cur_val < median):
return False
return True
评论列表
文章目录