-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Quoting @richelbilderbeek #90:
) {
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels