You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
) {
testit::assert(
"length(pars) is not five and/or shift_times is not null, set five parameters with no shift_times or ten parameters with non-null shift_times",
length(pars) ==5|| (length(pars) ==10&&!is.na(prop_type2_pool))
)
testit::assert(
"2 type islands cannot have species on the island initially",
is.na(prop_type2_pool) ||!is.na(prop_type2_pool) &&nonoceanic_pars[1] ==0
)
testit::assert(
"prop_type2_pool should either be NA for no type 2 species or value between 0 and 1",
is.na(prop_type2_pool) || (prop_type2_pool>=0&&prop_type2_pool<=1)
)
I enjoy this error checking!
But first, this error checking is already quite complex. Use a function
for each check instead: this will be easier to debug, easier to read,
easier to write.
Second, it is getting clear that the function
is actually doing two things: check for 5 or 10 parameters. I suggest that
this function quickly redirects to functions specialized on 5 or 10 parameters.
Of course, there should be little code duplication, so things done for both
5 and 10 parameters should be put into little functions as well.
The text was updated successfully, but these errors were encountered:
Quoting @richelbilderbeek #90:
The text was updated successfully, but these errors were encountered: