fix: unreachable chromid warning, shared mutable defaults, unclosed bed file handles - #6
Open
sanjaynagi-eit wants to merge 1 commit into
Open
fix: unreachable chromid warning, shared mutable defaults, unclosed bed file handles#6sanjaynagi-eit wants to merge 1 commit into
sanjaynagi-eit wants to merge 1 commit into
Conversation
sanjaynagi-eit
force-pushed
the
fix/correctness-issues
branch
from
August 13, 2026 21:46
c825491 to
c1a95a7
Compare
…ed files
Three unrelated correctness issues found while profiling.
1. The 'Multiple contigs above the specified chromosome length -c' warning
could never fire. c is an int (c = 1; c += 1) but was compared against the
string "2", so users assembling something with two chromosome-sized
contigs - chromids, or a -c set too low - silently got no hint. Three
copies, in the raven, flye and flye_long variants.
2. Mutable and import-time-evaluated default arguments in Plass.__init__ and
Assembly.__init__: 'filtered_out_contig_ids: list = []',
'plasmid_names: list = ["1"]', and three
'depth_df: pd.DataFrame() = pd.DataFrame({...})' defaults. The list
defaults are shared by every instance; the annotation 'pd.DataFrame()'
also constructs a throwaway DataFrame at import time, six times, and the
default value itself was a dummy {'col1': [1,2,3]} frame rather than an
empty one. All now default to None and are materialised per instance.
Assembly.__init__ also accepted chromosome_name and plasmid_names without
ever storing them; it does now.
3. non_chromosome.bed and chromosome.bed were opened with a bare open() and
never closed. samtools later reads both with -L, which worked only
because CPython's refcounting flushed them when the method returned.
Closed explicitly.
New tests/test_plass_class_defaults.py covers each: instances no longer share
default containers, supplied values still win, the DataFrame defaults are
empty, and the multiple-chromosome warning actually fires.
sanjaynagi-eit
force-pushed
the
fix/correctness-issues
branch
from
August 13, 2026 21:54
c1a95a7 to
53ebeac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Three unrelated correctness issues found while profiling. None are performance changes; opening them separately so the perf PRs stay reviewable.
1. The multiple-chromosome warning could never fire
cis an integer, soc == "2"is alwaysFalse. A user assembling something with two chromosome-sized contigs — chromids, or simply-cset too low — silently got no hint that this had happened, which is exactly the case the message exists for. Three copies, in the raven, flye and flye_long variants.2. Mutable and import-time-evaluated default arguments
.append().pd.DataFrame()in annotation position is not a type — it constructs and discards a DataFrame at import time, six times across the two classes.{"col1": [1,2,3], "col2": [4,5,6]}frame rather than an empty one, so an un-populatedPlasscarried fake data.All now default to
Noneand are materialised per instance.Separately,
Assembly.__init__acceptedchromosome_nameandplasmid_namesand then never stored them. It does now.3. BED file handles were never closed
Bare
open(), nowith, no.close().samtools view -Lreads both files later in the run, which works today only because CPython's refcounting happens to flush and close them when the method returns — it would break under a non-refcounting implementation, and it makes the ordering guarantee invisible. Closed explicitly.Tests
New
tests/test_plass_class_defaults.py: two instances no longer share default containers, explicitly supplied values still win, the DataFrame defaults are empty rather than dummy data, and the multiple-chromosome warning actually fires for an assembly with two chromosome-sized contigs.All existing tests pass (74 non-slow).