Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #372: Refactor formula dispatch #383

Merged
merged 6 commits into from
Oct 14, 2024
Merged

Issue #372: Refactor formula dispatch #383

merged 6 commits into from
Oct 14, 2024

Conversation

athowes
Copy link
Collaborator

@athowes athowes commented Oct 14, 2024

Description

This draft PR will close #372.

I am considering doing #382 as well since #372 involves reorganising the function locations. In doing so it seems easy to also fix the other function locations. I'd like to move quickly.

What has been done:

On #372:

  • epidist_formula is now a regular function which contains all processing that happens across models
  • It calls epidist_formula_model which dispatches on the class of data into the model specific part
  • Moved into new file formula.R and the tests are moved into a test-formula.R file

On #382:

  • Moves formula functions into formula.R

Edit: I'm going to let this get to passing tests and if it's quick and I can catch a reviewer I'll put the #382 into a new PR.

Checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have included the target issue or issues in the PR title in the for Issue(s) issue-numbers: PR title
  • I have read the contribution guidelines.
  • I have tested my changes locally.
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required.
  • My code follows the established coding standards.
  • I have added a news item linked to this PR.
  • I have reviewed CI checks for this PR and addressed them as far as I am able.

@athowes athowes changed the title Issue #382 and #372: Reorganise functions by functionality and refactor formula dispatch Issue #372: Refactor formula dispatch Oct 14, 2024
@athowes athowes marked this pull request as ready for review October 14, 2024 10:34
@seabbs seabbs self-requested a review October 14, 2024 10:57
@seabbs seabbs enabled auto-merge (squash) October 14, 2024 10:57
R/formula.R Outdated Show resolved Hide resolved
Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice. One small comment about opening up the default method now that this is optional.

@athowes
Copy link
Collaborator Author

athowes commented Oct 14, 2024

Actually we have the same issue in family:

#' Default method for defining a model specific family
#'
#' @inheritParams epidist_family_model
#' @param ... Additional arguments passed to method.
#' @family family
#' @export
epidist_family_model.default <- function(data, ...) {
  cli_abort(
    "No epidist_family_model method implemented for the class ", class(data),
    "\n", "See methods(epidist_family_model) for available methods"
  )
}

Can fix both here.

Edit: confirming that in epidist we call epidist_validate which already does this check, so for sure we don't need it.

…la (already check for model being in the right class in as_model() function)
@athowes athowes requested a review from seabbs October 14, 2024 11:31
Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. LGTM

@seabbs seabbs merged commit 9cc8abd into main Oct 14, 2024
7 checks passed
@seabbs seabbs deleted the formula-dispatch branch October 14, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor of epidist_formula to use S3
2 participants