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

compare() doesn't know how to show the difference for numbers that round up to the same value #63

Closed
bakaburg1 opened this issue Jan 13, 2021 · 2 comments

Comments

@bakaburg1
Copy link

Hello,

I guess this is the intended behaviour but I can't understand the logic:

if I compare numbers that round up to the same value I get this message:

> waldo::compare(c(1, 1.9343), c(1, 1.92))
old != new but don't know how to show the difference

while if they round up to different values I get:

> waldo::compare(c(1, 1.2), c(1, 1.92))
`old`: 1 1
`new`: 1 2

that is, the values get rounded up.

If I use waldo:::diff_element() the output is correct:

> waldo:::diff_element(c(1, 1.9343), c(1, 1.92))
`x`: "1" "1.9343"
`y`: "1" "1.92"  

The problem is that I discovered this behavior in testthat::expect_equal() so I cannot control how the comparison output is managed internally.

@hadley
Copy link
Member

hadley commented Jan 13, 2021

This is a bug — probably in my logic that tries to determine the minimum number of decimal places to display.

@hadley
Copy link
Member

hadley commented Feb 7, 2021

Another example: waldo::compare(0.21,0.23)

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