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

expect_equal() fails for numeric vectors containing Inf values #789

andypea opened this issue Aug 10, 2018 · 2 comments


None yet
3 participants
Copy link

commented Aug 10, 2018

Calls to expect_equal() fail whenever the values to be compared are numeric vectors with coincident entries having the value Inf. For example, on my machine, the following code:

library(testthat) expect_equal(c(0, Inf), c(1, Inf))

produces the error:

Error in is.character(message) : missing value where TRUE/FALSE needed

This should probably be fixed by handling Inf values explicitly in the function vector_equal_tol(), making the result consistent with a call to vector_equal(). Alternatively, mismatch_numeric() could be altered, so that it handles a diff argument containing entries which are neither TRUE nor FALSE.


@jimhester jimhester added the bug label Aug 10, 2018

@hadley hadley added this to the testthat 2.1.0 milestone Apr 1, 2019


This comment has been minimized.

Copy link

commented Apr 1, 2019

Minimal reprex:

compare(c(0, Inf), c(1, Inf))
#> Error in is.character(message): missing value where TRUE/FALSE needed

Created on 2019-04-01 by the reprex package (v0.2.1.9000)


This comment has been minimized.

Copy link

commented Apr 1, 2019

Even more minimal reprex:

vector_equal_tol(c(0, Inf), c(1, Inf))
#> [1] FALSE    NA

@hadley hadley closed this in 992ddd8 Apr 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.