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

Closed
andypea opened this issue Aug 10, 2018 · 2 comments
Closed

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

andypea opened this issue Aug 10, 2018 · 2 comments

Comments

@andypea
Copy link

@andypea andypea 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.

expect_equal_inf_bug.txt

@jimhester jimhester added the bug label Aug 10, 2018
@hadley hadley added this to the testthat 2.1.0 milestone Apr 1, 2019
@hadley
Copy link
Member

@hadley hadley commented Apr 1, 2019

Minimal reprex:

library(testthat)
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)

@hadley
Copy link
Member

@hadley hadley 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants