Skip to content

Move away from auto-detecting models #796

@SamuelBrand1

Description

@SamuelBrand1

At the moment,

#' Detect model type from model name
#'
#' Internal helper function to infer model type from naming conventions
#'
#' @param model_name Character string with model name
#' @return Character string with model type ("pyrenew", "timeseries", etc.)
#' @keywords internal
detect_model_type <- function(model_name) {
if (
grepl("^ts_", model_name) ||
grepl("timeseries", model_name, ignore.case = TRUE)
) {
return("timeseries")
} else if (grepl("epiautogp", model_name, ignore.case = TRUE)) {
return("epiautogp")
} else {
# Default to pyrenew for backward compatibility
return("pyrenew")
}
}

is a pretty weak pattern since the point of introducing an S3 generic to handle model specific post-processing was to avoid needing to add new parameters to all the required post-processing functions for any new model.

I think we should move to passing the model_type to dispatch on, assuming that we need a model_name which is distinct e.g. model_name = pyrenew_he with model_type = pyrenew.

This is connected to #789 since it is effectively a code organisation decision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions