-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
Modified search
to take in multiple strings
#4650
base: develop
Are you sure you want to change the base?
Conversation
I have modified the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4650 +/- ##
===========================================
- Coverage 99.21% 99.20% -0.02%
===========================================
Files 302 302
Lines 22858 22889 +31
===========================================
+ Hits 22679 22707 +28
- Misses 179 182 +3 ☔ View full report in Codecov by Sentry. |
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.
I did not test the code changes locally, but they were just renamings.
Can you add a test with multiple keys in the search? It looks like you only fixed the test for the output formatting
I have implemented the suggested changes and added tests for searching multiple strings as well. |
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.
Looks good to me, just needs an entry to the CHANGELOG before merging
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! Happy to approve/merge after these suggestions.
Actually, in the case of a partial match, would it be better to indicate that it is such? For example, model.variables.search(["NotAVariable", "concentration"]) now returns
but we could say something like
because we do have a match here for |
In cases where some keys have an exact match while others only have a best match, what should the expected result be? Should we only prioritize the exact matches in such cases or should we also have the best matches printed separately? |
Do you mean the case where we have an exact match for If I understood your question correctly, then an input as follows: model.variables.search(["Electrolyte concentration", "Electrolite concentration"]) should return something, in my opinion, like:
We can figure out the best way to display the output later. There is also a case to be made to say that this improvement to the search functionality to accept multiple strings means that the result is returned for only the string that does return a match, but we are not really implementing a search engine, so I feel it is acceptable to have all results for all input strings (as if we are looping over them in the search). @brosaplanella, what do you think? |
For now i have modified the method to search for exact matches having all the model.variables.search(["electrolyte", "concentration"]) Since both terms are present together in a single key, the result will be: Results for 'Electrolyte concentration': ['Electrolyte concentration'] For the cases where there are no such matches it will iterate over each string individually and give results as such: model.variables.search(["RandomKey", "elecrtolyte concentration","electrolite"]) will give results as:
|
Description
Fixes #4629
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: