Open EmilHvitfeldt opened 6 years ago
I like this as a general principle for writing functions, and vctrs's lossy cast warning functions are pretty nice for this. What's nice about it is that integerish things like the numeric 2
don't trigger the warning but 2.2
would. I personally don't think this is specific enough to be a model principle, but could see it living as a general principle in the functions chapter of the next version of advanced R (but I have no control over that). Maybe Max has a different opinion though because it is a useful point overall.
Certainly I think we should have a section about input validation, potentially listing some easy tests to do to avoid mistakes like this.
I don't know if this fits within this repo so please bear with me.
I have been thinking about what happens when we check the type of the arguments we pass into our models, and for the most part that task is fairly easy. But I feel we have overlooked the case when we are concerned with argument such as
times
,epochs
andmtry
that require integers. Often the approach is to round down the double silently which I think is a little dangerous.Examples
I feel like this problem is already being looked at in the vctrs package with
vec_cast
but might be something you should consider when implementing models in R.