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

fix: check near #194

Merged
merged 4 commits into from
Nov 29, 2023
Merged

fix: check near #194

merged 4 commits into from
Nov 29, 2023

Conversation

strasdat
Copy link
Member

@strasdat strasdat commented Nov 28, 2023

  • implement FARM_NEAR according to best practices
    • in a symmetric form such that relativeCloseness(x, y) == relativeCloseness(y, x)
    • detecting NANs and PANIC in that case
  • adding in FARM_ABS_NEAR if absolute comparison is needed instead: |x-y| <= thr
  • fix newly detected bug (test was erroneously passing for a NAN value)

Fixes / clarifies issue discussed in this comment: #89 (comment)

Copy link
Contributor

@isherman isherman left a comment

Choose a reason for hiding this comment

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

I'm not crazy about the names in the public API: "FARM_ASSERT_NEAR" and "FARM_ASSERT_ABS_NEAR".

I think it's because I would use the "FARM_ASSERT_ABS_NEAR" whether or not I was dealing with numbers that were "near" each other. That's the use case that originally confused me about the API.

Here's another example:

double t_a = getTimestamp("a");
double t_b = getTimestamp("b");

// Sanity check that event a occurred within an hour of event b
FARM_ASSERT_ABS_NEAR(t0, t1, 60 * 60);

Could we follow the convention used in Catch2 and name them FARM_ASSERT_WITHIN_ABS and FARM_ASSERT_WITHIN_REL?

cpp/farm_ng/core/logging/check_near.h Outdated Show resolved Hide resolved
cpp/farm_ng/core/logging/check_near.h Outdated Show resolved Hide resolved
cpp/farm_ng/core/logging/check_near.h Outdated Show resolved Hide resolved
cpp/farm_ng/core/logging/check_near.h Outdated Show resolved Hide resolved
@strasdat
Copy link
Member Author

@isherman thanks for the naming suggestion, I adopted them as proposed.

@strasdat strasdat merged commit 75c1332 into main Nov 29, 2023
11 checks passed
@strasdat strasdat deleted the chec-near branch November 29, 2023 15:05
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