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_date NA missing behavior inconsistent with assert_numeric and others #256

Open
dshemetov opened this issue Jan 26, 2024 · 1 comment

Comments

@dshemetov
Copy link

dshemetov commented Jan 26, 2024

Hello, first off thank you for this excellent package.

Secondly, this behavior seems inconsistent to me:

library(checkmate)

# Pass
assert_numeric(c(5, NA))
assert_date(c(Sys.Date(), NA))
# Pass
assert_numeric(NA)
assert_character(NA)
assert_integerish(NA)
assert_double(NA)
# Doesn't pass
assert_date(NA)
# Error: Assertion on 'NA' failed: Must be of class 'Date', not 'logical'.

This happens even though they all have the same defaults for any.missing = TRUE. Thoughts? Thanks for your time.

@tdeenes
Copy link
Contributor

tdeenes commented Jan 26, 2024

In your second example, c(Sys.Date(), NA) creates a Date vector, this is why it passes. @mllg Maybe check_date should get a typed.missing argument, too? Also related to #236

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