crmPack
crmPack copied to clipboard
open interval constraint in assertions at checkmate
Why the first test gives TRUE, instead of FALSE, while the second one is ok? How to check that x > 1, not x >= 1?
> test_number(x = 1, lower = 1 + .Machine$double.xmin)
[1] TRUE
> test_number(x = 0, lower = .Machine$double.xmin)
[1] FALSE
More evidences:
> assert_number(1, lower = 1 + .Machine$double.xmin)
> assert_number(0.9, lower = 1 + .Machine$double.xmin)
Error: Assertion on '0.9' failed: Element 1 is not >= 1.
> assert_number(0, lower = .Machine$double.xmin)
Error: Assertion on '0' failed: Element 1 is not >= 2.22507e-308.
This results from finite arithmetic precision. Possibly, we could create a new wrapper-helper, e.g. test_number_bounds that checks whether numbers are in a given interval using <, >.