-
-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improves search
to handle smaller search terms.
#4735
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4735 +/- ##
========================================
Coverage 98.70% 98.70%
========================================
Files 303 303
Lines 23312 23330 +18
========================================
+ Hits 23009 23027 +18
Misses 303 303 ☔ View full report in Codecov by Sentry. |
Could I get a review on this one? |
@medha-14 Sorry, there is a bit of a backlog due to the upcoming release and everyone coming back from vacation. Don't worry, we will review this shortly |
Thank you for the update! I just thought you missed this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think min_similarity
could be slightly higher here because the threshold here is too low and can lead to false positives in the search. But, at the same time, being able to resolve potential typos in the search query would require a lower threshold. This makes me feel that we could expose it with a sensible default, but I don't yet know what a sensible default would be. It should be higher than the current 40%, though. In-line comment about this below:
src/pybamm/util.py
Outdated
@@ -163,14 +185,24 @@ def search(self, keys: str | list[str], print_values: bool = False): | |||
search_keys = [k.strip().lower() for k in keys if k.strip()] | |||
|
|||
known_keys = list(self.keys()) | |||
known_keys.sort() | |||
|
|||
min_similarity = 0.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
min_similarity
is also defined above, so it gets defined twice. How about making it an argument for _find_matches()
?
Follow-up question: do you think it would make sense to expose it publicly for users through search()
as well?
Sorry for the delayed response. I think it's important to clarify that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @medha-14! Let's go ahead with this for now, I feel your explanation adds the necessary context. I'm happy to approve this once we resolve https://github.com/pybamm-team/PyBaMM/pull/4735/files#r1905523299, as min_similarity
is defined in two different locations, and if we have to do that, I think making it an argument that's passed to _find_matches()
makes sense, along with documenting it.
I’ve made |
Description
Fixes #4734
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python -m pytest
(or$ nox -s tests
)$ python -m pytest --doctest-plus src
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: