Skip to content

Allow tolerance for comparing float scores #694

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

Merged
merged 2 commits into from
Jun 10, 2025

Conversation

alonre24
Copy link
Collaborator

@alonre24 alonre24 commented Jun 10, 2025

Describe the changes in the pull request

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

@alonre24 alonre24 requested review from Copilot and GuyAv46 June 10, 2025 14:15
@alonre24 alonre24 changed the title Allow tolerance for comparing scores floats Allow tolerance for comparing float scores Jun 10, 2025
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@alonre24 alonre24 requested a review from Copilot June 10, 2025 14:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a tolerance threshold for comparing float scores in query results.

  • Introduces an EPSILON constant for tolerance
  • Implements a helper function (double_eq) utilizing the tolerance
  • Updates the comparator function to use the new tolerance-based equality check
Comments suppressed due to low confidence (2)

src/VecSim/utils/query_result_utils.h:14

  • [nitpick] Consider renaming EPSILON to a more descriptive name (e.g., QUERY_RESULT_EPSILON) to clarify its purpose.
#define EPSILON (1e-6)

src/VecSim/utils/query_result_utils.h:16

  • [nitpick] Consider renaming the function 'double_eq' to a more expressive name like 'nearlyEqual' to better indicate its purpose for tolerance-based comparison.
inline bool double_eq(double a, double b) { return fabs(a - b) < EPSILON; }

Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.65%. Comparing base (ca1137a) to head (a1a30db).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #694   +/-   ##
=======================================
  Coverage   96.65%   96.65%           
=======================================
  Files         121      121           
  Lines        6756     6757    +1     
=======================================
+ Hits         6530     6531    +1     
  Misses        226      226           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alonre24 alonre24 added this pull request to the merge queue Jun 10, 2025
Merged via the queue into main with commit 5589392 Jun 10, 2025
17 checks passed
@alonre24 alonre24 deleted the tolerance_for_comparing_float_scores branch June 10, 2025 17:08
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