We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d04e95 commit 30bd293Copy full SHA for 30bd293
src/Population.jl
@@ -212,7 +212,9 @@ end
212
# Return best 10 examples
213
function best_sub_pop(pop::P; topn::Int=10)::P where {P<:Population}
214
best_idx = sortperm([pop.members[member].cost for member in 1:(pop.n)])
215
- return Population(pop.members[best_idx[1:topn]])
+ # Ensure we don't try to access more elements than exist in the population
216
+ actual_topn = min(topn, pop.n)
217
+ return Population(pop.members[best_idx[1:actual_topn]])
218
end
219
220
function record_population(pop::Population, options::AbstractOptions)::RecordType
0 commit comments