Repository navigation
Conversation
Blank terms were dropped from search_keys but kept in original_keys, so zip() paired each result with the wrong term and the last term was never searched.
Contributor
|
| Project | PyBaMM |
| Branch | fix-fuzzydict-search-blank-terms |
| Testbed | bare-metal |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6019 +/- ##
==========================================
- Coverage 98.23% 98.22% -0.01%
==========================================
Files 350 350
Lines 36173 36173
==========================================
- Hits 35533 35532 -1
- Misses 640 641 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Description
FuzzyDict.searchlabels its results with the wrong search term when the list of terms contains a blank entry, and the last term is never searched:Expected:
Cause: blank terms are filtered out of
search_keysbut kept inoriginal_keys. The per-term loop zips the two lists, so after a blank entry every result is printed against the previous term, and the last term is dropped. The existing mixed-list test passes only because all of its terms match one key together, which takes the earlier "Results for" path and never reaches the zip.Fix: filter
original_keysfirst and buildsearch_keysfrom it, so the two lists always line up. The "Results for" message no longer needs its own blank filter.No linked issue; I found this by reading the code.
Type of change
Bug fix, with a CHANGELOG entry under
# [Unreleased]→## Bug fixes.Important checks:
ruff check/ruff format --checkon the changed filestests/unit/test_util.py(8 passed). The new case inTestSearch.test_url_gets_to_stdoutfails onmainand passes with the fix.AI-assisted (Claude). I reviewed the code and ran the tests.