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

assert does not always report errors #85

Closed
richardjtelford opened this issue Jun 5, 2019 · 4 comments
Closed

assert does not always report errors #85

richardjtelford opened this issue Jun 5, 2019 · 4 comments

Comments

@richardjtelford
Copy link

I've been having problems getting assert to print errors in a package I'm writing. Some calls to assert work properly and some don't.

Here is a reproducible example which gives the same symptoms.

#works  
assert(data.frame(x = c("a", "b")), in_set("b"), x)

Column 'x' violates assertion 'in_set("b")' 1 time
verb redux_fn predicate column index value
1 assert NA in_set("b") x 1 a

Error: assertr stopped execution

#doesn't work  
assert(data.frame(x = "a"), in_set("b"), x)

Error: assertr stopped execution

I think the problem is because in the latter example

 log.mat <- sapply(names(sub.frame), function(column) {
    this.vector <- sub.frame[[column]]
    return(apply.predicate.to.vector(this.vector, predicate))
  })

returns a vector rather than a matrix so colnames in

 errors <- lapply(colnames(log.mat),

returns NULL and the lapply doesn't run.

@tonyfischetti
Copy link
Owner

Sorry for the delay, checking this out now

tonyfischetti added a commit that referenced this issue Jun 11, 2019
@tonyfischetti
Copy link
Owner

Just fixed this issue! Thanks for noticing it :)
I'm going to try to address some other things and then I'll upload to CRAN. In the meantime, feel free to install it from github with devtools::install_github("ropensci/assertr")

@richardjtelford
Copy link
Author

Brilliant. assert now reports errors properly in my package.

@tonyfischetti
Copy link
Owner

Glad to here it. Thanks again for bringing the issue to my attention

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