Skip to content

Commit

Permalink
Rewritten competing hazards resoltion so that it does not call itself…
Browse files Browse the repository at this point in the history
… within the function. This also removed the "set_relative_rates" part of the competing hazards, and now we have args, such that the competing hazards object can still store the relative rates it needs, but retains flexibility.

Calculate_infections has been rewritten as four functions: calculate_falciparum_infections, calculate_vivax_infections, treatment_prophylaxis_efficacy and pev_efficacy.

Infection_outcome_process has been split into falciparum and vivax _infection_outcome_process.

Tests have been adjusted to reflect these changes.
  • Loading branch information
RJSheppard committed Oct 14, 2024
1 parent e2adee2 commit 3b833ff
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 277 deletions.
18 changes: 6 additions & 12 deletions R/competing_hazards.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,25 @@ CompetingOutcome <- R6::R6Class(

self$target <- individual::Bitset$new(size)
self$rates <- NULL
self$relative_rates <- NULL
self$args <- NULL
},
set_rates = function(target, rates){
set_rates = function(target, rates, ...){
stopifnot(target$size() == length(rates))

self$target$copy_from(target)
self$rates <- rates
},
set_relative_rates = function(target, relative_rates){
stopifnot(target$size() == length(relative_rates))

self$target$copy_from(target)
self$relative_rates <- relative_rates
self$args <- list(...)
},
execute = function(t, target){
private$targeted_process(t, target)
do.call(private$targeted_process, list(t, target, self$args))
},
reset = function() {
self$target$clear()
self$rates <- NULL
self$relative_rates <- NULL
self$args <- NULL
},
target = NULL,
rates = NULL,
relative_rates = NULL
args = NULL
)
)

Expand Down
Loading

0 comments on commit 3b833ff

Please sign in to comment.