Skip to content

Fix sequence emptiness checks in Python scorers - #513

Open
peterolkhov wants to merge 1 commit into
rapidfuzz:mainfrom
peterolkhov:codex/fix-python-sequence-emptiness
Open

peterolkhov wants to merge 1 commit into
rapidfuzz:mainfrom
peterolkhov:codex/fix-python-sequence-emptiness

Conversation

@peterolkhov

Copy link
Copy Markdown

The Python backend uses sequence truth values to check for empty inputs. That raises ValueError for multi-element NumPy arrays, and treats array([0]) as empty: QRatio returns 0 for two identical inputs instead of 100. The compiled backend handles these inputs correctly.

Use sequence length in the six affected guards in Jaro, LCSseq and the fuzzy scorers. Keep the existing missing-value checks and conversion order. No new runtime dependency.

The regression tests cover direct and processor-produced sequences, strided arrays, empty/zero inputs, cutoffs and process helpers across both backends.

Validation on Ubuntu/Python 3.12.12 and Windows/Python 3.12.10 with NumPy 2.2.6:

  • The frozen public probe changes from 23/44 passing on the Python backend to 44/44; CPP remains 44/44.
  • All 468 applicable added regression cases pass per backend; 24 raw-LCS missing-value cases are explicitly skipped because those scorers do not define missing-value scores.
  • Typing, scorer checks, Black/Ruff/pre-commit, docs, PyInstaller and original/candidate cx_Freeze functional tests pass.

The hosted run remains failed: the unchanged base has one CPP-suite failure and four Python-suite failures in this environment, and the candidate has the exact same existing outcomes/messages. All 543 original cases were compared by identity. The shared failure is the Prefix cutoff boundary; Python mode also has three process_cpp TypeError expectations that fail on the base. No new existing-case failures were introduced, and none of these failures was waived or reported as passing.

AI-assisted patch with independent source and native-result review.

@maxbachmann

Copy link
Copy Markdown
Member

Can you rebase on the latest develop? The change itself looks good.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants