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

Tolerance behaves differently than (naively) expected #188

Closed
GraphZal opened this issue Feb 13, 2024 · 1 comment
Closed

Tolerance behaves differently than (naively) expected #188

GraphZal opened this issue Feb 13, 2024 · 1 comment

Comments

@GraphZal
Copy link

When using compare on vectors (lists, data.frames, etc), the tolerance paremater works differently than a naive user would expect. Rather than comparing each entry's deviation separately, it considers the mean deviation of all deviating entries.
While this matches the documented behavior, it probably isn't what a user would intuitively expect.

Contrived minimal example:

vec1 <- rep(1, 1000)
vec2 <- rep(1.01, 1000)
vec2[1000] <- 10
waldo::compare(vec1, vec2, tolerance = 0.1)

results in
✔ No differences
while many users would probably expect to see the last line (and only the last line) highlighted as difference.

@hadley
Copy link
Member

hadley commented May 6, 2024

While I somewhat regret copying the tolerance behaviour of all.equal() (because it's so hard to understand), unfortunately it's very hard to change the behaviour now since so many test are now likely to depend on it.

@hadley hadley closed this as completed May 6, 2024
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