Skip to content

Commit

Permalink
patch for doubling edge case (#64)
Browse files Browse the repository at this point in the history
It was possible with the previous version where if the doubling was very
close the resizing that you could end up in a situation where it fails
to resize and it outgrows the container after subsampling.
  • Loading branch information
tlnagy authored Apr 25, 2023
1 parent 30393bd commit 587d8ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ function select(setup::GrowthScreen,
sample!(1:num_cells, picked, replace=false)
@debug "Selecting $(length(picked))"
else
# if we have room to grow, don't subsample, just shuffle and grow
# the available space
# if we have room to grow, don't subsample, just shuffle
picked .= 0
picked[1:num_cells] .= shuffle(1:num_cells)
end

# if next doubling could exceed the space available, grow the
# preallocated arrays
if num_cells * 4 > length(output_c)
resize!(output_c, num_cells * 4)
resize!(output_p, num_cells * 4)
end
Expand Down

0 comments on commit 587d8ca

Please sign in to comment.