Skip to content

fix: accept zero WordEmbeddingDistance thresholds - #841

Open
emecii wants to merge 1 commit into
QData:masterfrom
emecii:fix/word-embedding-zero-threshold
Open

fix: accept zero WordEmbeddingDistance thresholds#841
emecii wants to merge 1 commit into
QData:masterfrom
emecii:fix/word-embedding-zero-threshold

Conversation

@emecii

@emecii emecii commented Sep 7, 2026

Copy link
Copy Markdown

What does this PR do?

Summary

This fixes WordEmbeddingDistance so that 0.0 is treated as an explicitly selected threshold rather than as an omitted value.

Additions

  • Regression coverage using a small in-memory embedding.

Changes

  • Use explicit None checks when validating the mutually exclusive min_cos_sim and max_mse_dist options.
  • Apply both selected metrics when their threshold is 0.0.

0.0 is a meaningful boundary: cosine similarity must be non-negative, and MSE distance must be zero. The previous truthiness checks rejected those constructor calls and would have skipped enforcement if accepted.

Deletions

  • None.

Validation

  • python -m pytest tests/test_word_embedding.py -k word_embedding_distance -q — 5 passed
  • python -m pytest tests/test_constraints -q — 8 passed
  • make lint — passed

The full tests/test_word_embedding.py run was not used as the acceptance check because an existing network-backed embedding test stalled while downloading its artifact; the deterministic selected tests completed normally.

Checklist

  • The title summarizes the contribution.
  • This is ready for review, not a draft.
  • Relevant tests were added and passed.
  • Existing relevant constraint tests passed.
  • No new public methods or modules were added.

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.

1 participant