Skip to content
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

When using extractOne with score_cutoff, please return a (None, None, None) instead of None #200

Closed
John-Schreiber opened this issue Mar 11, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@John-Schreiber
Copy link

This would simplify using extractOne for lists with items with no matches.

@maxbachmann maxbachmann added the enhancement New feature or request label Mar 11, 2022
@maxbachmann
Copy link
Member

maxbachmann commented Mar 12, 2022

I will still need to think about this change. I understand this can be helpful when doing:

a, b, c = extractOne(...)

However it has a couple of disadvantages as well:

  • different api than fuzzywuzzy/thefuzz
  • breaking change in rapidfuzz (can not be changed before v3.0.0)
  • makes other legitimate use cases harder:
if res := extractOne(...):
    a, b, c = res

In the long run I will probably guide people to this new API: #188
The final API is not clear yet, but this will likely raise a ValueError for an empty result, but allows the user to pass an initial value similar to numpy (https://numpy.org/doc/stable/reference/generated/numpy.amax.html#numpy.amax):

Compare(...).max() -> ValueError
Compare(...).max(initial=(None, 0, None)) -> (None, 0, None)

@John-Schreiber
Copy link
Author

Thank you

@i30817
Copy link

i30817 commented Apr 14, 2022

I use :

a, b, c = extractOne(...) or (None, 0, None)

Speaking of that, i'm not sure it's a good idea to return None for the number in the middle.

@maxbachmann
Copy link
Member

a, b, c = extractOne(...) or (None, 0, None)

Sounds like a good solution to @John-Schreiber's problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants