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

unwanted warning with makeAssertCollection #242

Open
TanguyBarthelemy opened this issue Jun 19, 2023 · 0 comments
Open

unwanted warning with makeAssertCollection #242

TanguyBarthelemy opened this issue Jun 19, 2023 · 0 comments

Comments

@TanguyBarthelemy
Copy link

I'm trying to group my assertion with the functions makeAssertCollection and reportAssertions.
Only, I realized that for some values, the function reportAssertions adds unwanted warnings.

Here is a simple example with two functions that are doing the same job : testing if x is an int

library("checkmate")

f1 <- function(x) {
    x_corr <- checkmate::assert_int(
        x = x, coerce = TRUE)
    return(invisible(x_corr))
}

f2 <- function(x) {
    coll <- checkmate::makeAssertCollection()
    x_corr <- checkmate::assert_int(
        x = x, coerce = TRUE, add = coll)
    checkmate::reportAssertions(coll)
    return(invisible(x_corr))
}

With x = Inf :

f1(x = Inf)
Error in f1(Inf) :
Assertion on 'x' failed: Must be of type 'single integerish value', not 'double'.
f2(x = Inf)
Error in f2(Inf) : 1 assertions failed:
 * Variable 'x': Must be of type 'single integerish value', not 'double'.
In addition: Warning message:
In setNames(as.integer(round(x, 0L)), names(x)) :
  NAs introduced by coercion to integer range

Is it possible to suppress these warnings (which are not related to the evaluation of the assertion for the variable x)?

@TanguyBarthelemy TanguyBarthelemy changed the title unwanted warning with makeAssertCollection unwanted warning with makeAssertCollection Jun 20, 2023
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