Fix random.sample call to be compatible with python 3.12 #273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue in the
partition
module where therandom.sample
function caused an error in Python versions 3.11 and 3.12, as reported in issue #268.While PR #255 added support for Python 3.12, this specific issue has been missed. The
random.sample
function is only called when the number of genomes exceeds the chunk size, which defaults to 500. Since the CI tests run with only 50 genomes, this bug wasn't detected.To verify the fix, you can run the
partition
command with a chunk size smaller than the number of genomes:cd testingDataset ppanggolin annotate --fasta genomes.fasta.list --output stepbystep --cpu 12 ppanggolin cluster -p stepbystep/pangenome.h5 --cpu 12 ppanggolin graph -p stepbystep/pangenome.h5 ppanggolin partition --output stepbystep -f -p stepbystep/pangenome.h5 --cpu 12 --chunk_size 40