Skip to content

Fix HalfVector equality for signed zero - #164

Open
chaduo wants to merge 1 commit into
pgvector:masterfrom
chaduo:fix/halfvector-numeric-equality
Open

chaduo wants to merge 1 commit into
pgvector:masterfrom
chaduo:fix/halfvector-numeric-equality

Conversation

@chaduo

@chaduo chaduo commented Oct 13, 2026

Copy link
Copy Markdown

HalfVector compares its uint16 storage rather than its numeric values, so vectors containing +0.0 and -0.0 compare unequal. Small positive and negative values that both round to zero expose the same issue. Vector and HalfVector in v0.4.2 use numeric equality.

Compare the decoded values instead. Keep the existing type check and preserve the stored sign bits, text serialization, and binary serialization. The regression tests cover direct construction, float16 underflow, text decoding, and binary decoding.

Validation: the five new cases failed on the unchanged implementation. The focused HalfVector, Vector, SparseVector, and Bit suites pass (60 passed, 8 skipped because SciPy is not installed). No PostgreSQL integration suite was run.

Prepared with assistance from OpenAI Codex. No independent human review is implied.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants