Created
April 9, 2016 18:30
-
-
Save dholstius/9b6db1c08e9d95925e05333fbe6f1405 to your computer and use it in GitHub Desktop.
Basic insurance against bad args to .Fortran() calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval({ | |
ensure_nonnull <- ensures_that(!is.null(.) ~ "Must not be NULL" ) | |
ensure_nonempty <- ensures_that(length(.) > 0 ~ "Must not be empty", +ensure_nonnull ) | |
ensure_finite <- ensures_that(all(is.finite(.)) ~ "Must be finite", +ensure_nonempty ) | |
ensure_positive <- ensures_that(all(. > 0) ~ "Must be positive", +ensure_finite ) | |
ensure_nonnegative <- ensures_that(all(. >= 0) ~ "Must be positive or zero", +ensure_finite ) | |
ensure_unique <- ensures_that(length(unique(.)) == 1) | |
}) | |
# Wrapped in `eval({...})` b/c otherwise RStudio will complain about syntax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment