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

NA handling bug in testing a_j = a_c #11

Open
davidorme opened this issue Jun 17, 2021 · 0 comments
Open

NA handling bug in testing a_j = a_c #11

davidorme opened this issue Jun 17, 2021 · 0 comments

Comments

@davidorme
Copy link
Contributor

Hi,

This line introduces a problem with NA values:

https://github.com/stineb/rpmodel/blob/master/R/rpmodel.R#L437

In the presence of NAs (but no other problems) the test fails:

> any(c(FALSE, NA))  # returns NA
[1] NA
> if(any(c(FALSE, NA))) { stop('a_j!=a_c')}  # if() statement chokes,
Error in if (any(c(FALSE, NA))) { : missing value where TRUE/FALSE needed

With grid maps as inputs, NAs are pretty likely and are handled by all steps up to this one. One alternative here is all.equal, which handles NAs and allows a tolerance to be set:

> all.equal(c(1,2,3,4, NA), c(1,2,3,4.001, NA), tol=0.001)
[1] TRUE
> all.equal(c(1,2,3,4, NA), c(NA, 2,3,4.001, NA), tol=0.001)
[1] "'is.NA' value mismatch: 2 in current 1 in target"

It would probably be useful to handle $a_j != a_c$ and mismatched NA values separately though? So trap the output of that all.equal and report separately or perhaps use a separate xor(is.na(a_j), is.na(a_c))

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

1 participant