Repository navigation
fix: return all pairs from ThresholdCounter.most_common() when n is omitted - #460
Closed
nikolauspschuetz wants to merge 1 commit into
Closed
nikolauspschuetz wants to merge 1 commit into
nikolauspschuetz wants to merge 1 commit into
Conversation
…mitted
The guard "if not n or n <= 0" treated the default n=None as falsy and
returned [] immediately, so most_common() (n omitted) returned nothing
even for a populated counter, contradicting the docstring ("If n is
omitted, returns all the pairs") and making the later "if n is None"
branch dead code. Guard only on an explicit non-positive n.
mahmoud
added a commit
that referenced
this pull request
Sep 7, 2026
Fold #463, #466, #476, #478, #460, #459, and #477 with focused regressions and 26.2.0 release notes. Verified 672 local tests and the full GitHub Actions matrix before merge. Co-authored-by: Ali Zulfiqar <codewithfourtix@gmail.com> Co-authored-by: Guo Jiarui <799423879@qq.com> Co-authored-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com> Co-authored-by: Raiyan Zaman <77029110+rzaman8677@users.noreply.github.com>
Owner
|
Folded into #481 with credit (Co-authored-by). Thanks! |
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.
ThresholdCounter.most_common()returned[]instead of all pairs when n is omitted: the guardif not n or n <= 0: return []treats the defaultn=Noneas falsy and returns early — contradicting the docstring ("If n is omitted, returns all the pairs") and leaving the subsequentif n is None ...branch unreachable.Guards only on an explicit non-positive
n, somost_common()returns all pairs whilemost_common(0)/most_common(-1)still return[]. Extendstest_threshold_counter.Verified: on a populated counter
most_common()now returns all pairs (was[]); zero/negative still return[].Developed with AI assistance (Claude Code); I directed, reviewed, and verified it locally.