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

Relative comparisons? #1832

Closed
StatsMan53 opened this issue Jun 30, 2023 · 1 comment
Closed

Relative comparisons? #1832

StatsMan53 opened this issue Jun 30, 2023 · 1 comment

Comments

@StatsMan53
Copy link

expect_equal does relative comparisons for values greater than one in magnitude, but does decimal place comparisons for values less than one in magnitude. Is there any way short of writing a custom helper function to do relative comparisons for all nonzero expectations?

For instance, if you are developing a probability calculation, then 1e-11 should be an epic fail for an expectation of 1e-300, but expect_equal considers it a pass. I have tried tolerance with both editions, but do not obtained the desired behavior.

@hadley
Copy link
Member

hadley commented Jul 26, 2023

If you don't get the behaviour that you want with the built-in tools, yes, you'll need to write it yourself.

It would be nice to do better in (e.g.) waldo::compare() but at this point making any changes to the algorithm is expensive because it may cause tests to break in CRAN packages, and those tests will need to be fixed prior to submission.

@hadley hadley closed this as completed Jul 26, 2023
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

No branches or pull requests

2 participants