Add an argument for open intervals in assert_numeric
Currently lower acts as greater than or equal (>=) to lower. Would it be possible to add an another argument that would act as >? Or maybe something like boolean lower.eq that would decide whether equality is allowed.
Obviously the same goes for upper.
One can use a trick with the machine epsilon, i.e. assert_numeric(0, lower = .Machine$double.eps), but neither the code nor the error message (Error: Assertion on '0' failed: Element 1 is not >= 2.22045e-016.) is elegant. The same trick used for something other than zero may result in an even more confusing error message, i.e.
assert_numeric(1, lower = 1 + .Machine$double.eps)
leading to Error: Assertion on '1' failed: Element 1 is not >= 1..
Yes, that is possible. However, I am currently busy with other projects, so it will take a while.
That's great, thanks!
I needed this earlier today, and I wrote a wrapper (that I didn't think was all that great, but it worked for my immediate need).
As I was thinking about how to implement this, I think that adding lower.condition = ">=" and upper.condition = ">=" would be the most straight-forward ways to do this. The alternative for lower.condition would be ">" and the alternative for upper.condition would be "<".
Using this interface would allow:
- backward compatibility,
- a clear interface for changing the condition, and
- different decisions for the lower and upper bounds.