diff --git a/pacehrh/DESCRIPTION b/pacehrh/DESCRIPTION index 0f82c4e7..d26924a1 100644 --- a/pacehrh/DESCRIPTION +++ b/pacehrh/DESCRIPTION @@ -45,12 +45,6 @@ Collate: 'pace_utils.R' 'pace_lint.R' 'pace_trace.R' - 'pace_pop_pyramid_class.R' - 'pace_task_params_class.R' - 'pace_add_method.R' - 'pace_getValue_method.R' - 'pace_setFromVector_method.R' - 'pace_setValue_method.R' 'pace_config.R' 'pace_pop_rates_config.R' 'pace_exp_control.R' diff --git a/pacehrh/NAMESPACE b/pacehrh/NAMESPACE index 2d2c677b..e4073709 100644 --- a/pacehrh/NAMESPACE +++ b/pacehrh/NAMESPACE @@ -25,7 +25,6 @@ export(PlotPyramids) export(PlotResultsFertilityRates) export(PlotResultsMortalityRates) export(PlotResultsPopulationCurve) -export(PopulationPyramid) export(ReadAndCollateSuiteResults) export(ReadScenario) export(RunExperiments) @@ -35,11 +34,8 @@ export(SaveSuiteDemographics) export(SaveSuiteResults) export(SetGlobalStartEndYears) export(SetRoundingLaw) -export(TaskParameters) export(Trace) export(UpdateScenario) -exportClasses(PopulationPyramid) -exportClasses(TaskParameters) import(data.table) importFrom(dplyr,group_by) importFrom(dplyr,summarize) diff --git a/pacehrh/R/pace_add_method.R b/pacehrh/R/pace_add_method.R deleted file mode 100644 index ce3a12aa..00000000 --- a/pacehrh/R/pace_add_method.R +++ /dev/null @@ -1,45 +0,0 @@ -# #' @exportMethod add -#' -methods::setGeneric( - name = "add", - def = function(obj1, obj2) - { - standardGeneric("add") - } -) - -#' Add Two PopulationPyramid Objects Together -#' -#' @param obj1 \code{PopulationPyramid} object -#' @param obj2 \code{PopulationPyramid} object -#' -#' @return Updated \code{PopulationPyramid} object -#' -methods::setMethod( - f = "add", - signature = c("PopulationPyramid", "PopulationPyramid"), - definition = function(obj1, obj2) - { - obj1@values <- obj1@values + obj2@values - return(obj1) - } -) - -#' Add Two TaskParameters Objects Together -#' -#' @param obj1 \code{TaskParameters} object -#' @param obj2 \code{TaskParameters} object -#' -#' @return Updated \code{TaskParameters} object -#' -methods::setMethod( - f = "add", - signature = c("TaskParameters", "TaskParameters"), - definition = function(obj1, obj2) - { - assertthat::assert_that(length(obj1@values) == length(obj2@values)) - - obj1@values <- obj1@values + obj2@values - return(obj1) - } -) diff --git a/pacehrh/R/pace_getValue_method.R b/pacehrh/R/pace_getValue_method.R deleted file mode 100644 index cebc36c6..00000000 --- a/pacehrh/R/pace_getValue_method.R +++ /dev/null @@ -1,30 +0,0 @@ -# #' @exportMethod getValue -#' -methods::setGeneric( - name = "getValue", - def = function(object, label) - { - standardGeneric("getValue") - } -) - -methods::setMethod( - f = "getValue", - signature = c("TaskParameters", "character"), - definition = function(object, label) - { - assertthat::is.string(label) - - index <- which(object@labels == label) - - if (length(index) == 1){ - return(object@values[index]) - } else if (length(index) == 0){ - traceMessage(paste("Invalid task label: ", label, sep = "")) - return(NULL) - } else { - traceMessage(paste("Duplicate task label: ", label, ". Using first instance.", sep = "")) - return(object@values[index[1]]) - } - } -) diff --git a/pacehrh/R/pace_pop_pyramid_class.R b/pacehrh/R/pace_pop_pyramid_class.R deleted file mode 100644 index 32533edd..00000000 --- a/pacehrh/R/pace_pop_pyramid_class.R +++ /dev/null @@ -1,31 +0,0 @@ -.defaultPyramidSize <- length(GPE$ages) - -#' Population Pyramid Class -#' -#' @slot length numeric -#' @slot values numeric -#' -#' @return Class of type \code{PopulationPyramid} -#' -#' @export PopulationPyramid -#' @exportClass PopulationPyramid -#' -PopulationPyramid <- setClass( - # Set the name for the class - "PopulationPyramid", - - # Define the variables - slots = c( - length = "numeric", - values = "numeric" - ), - - prototype = list(values = replicate(.defaultPyramidSize, 0.0), - length = .defaultPyramidSize) -) - -setValidity("PopulationPyramid", - function(object){ - if (length(object@values) == object@length) return(TRUE) - else paste("wrong length") - }) diff --git a/pacehrh/R/pace_population_config.R b/pacehrh/R/pace_population_config.R index 92162a70..42f58b4b 100644 --- a/pacehrh/R/pace_population_config.R +++ b/pacehrh/R/pace_population_config.R @@ -6,8 +6,8 @@ #' #' @param sheetName Sheet name from the model input Excel file #' -#' @return List with three \code{PopulationPyramid} objects: -#' \code{female}, \code{male} and \code{total} +#' @return Tibble with three population pyramid fields: +#' \code{Female}, \code{Male} and \code{Total} #' loadInitialPopulation <- function(sheetName = "TotalPop"){ popData <- readxl::read_xlsx(GPE$inputExcelFile, sheet = sheetName) diff --git a/pacehrh/R/pace_setFromVector_method.R b/pacehrh/R/pace_setFromVector_method.R deleted file mode 100644 index 66282c92..00000000 --- a/pacehrh/R/pace_setFromVector_method.R +++ /dev/null @@ -1,32 +0,0 @@ -# #' @exportMethod setFromVector -#' -methods::setGeneric( - name = "setFromVector", - def = function(object, values) - { - standardGeneric("setFromVector") - } -) - -#' Set Pyramid Age Values -#' -#' @param object PopulationPyramid object -#' @param values Vector of values to copy into PopulationPyramid object -#' -#' @return Updated \code{PopulationPyramid} object -#' -methods::setMethod( - f = "setFromVector", - signature = c("PopulationPyramid", "numeric"), - definition = function(object, values) - { - assertthat::assert_that(length(values) == length(GPE$ages)) - assertthat::assert_that(is.numeric(values) == TRUE) - - # Clear any names on the vector - names(values) <- NULL - - object@values = values - return(object) - } -) diff --git a/pacehrh/R/pace_setValue_method.R b/pacehrh/R/pace_setValue_method.R deleted file mode 100644 index be15cf2e..00000000 --- a/pacehrh/R/pace_setValue_method.R +++ /dev/null @@ -1,9 +0,0 @@ -# #' @exportMethod setValue -#' -methods::setGeneric( - name = "setValue", - def = function(object, label, value) - { - standardGeneric("setValue") - } -) diff --git a/pacehrh/R/pace_task_params_class.R b/pacehrh/R/pace_task_params_class.R deleted file mode 100644 index e766b04b..00000000 --- a/pacehrh/R/pace_task_params_class.R +++ /dev/null @@ -1,26 +0,0 @@ -#' Task Parameters Class -#' -#' @slot values numeric matrix -#' -#' @return Class of type \code{TaskParameters} -#' -#' @export TaskParameters -#' @exportClass TaskParameters -#' -TaskParameters <- setClass( - "TaskParameters", - - slots = c( - values = "matrix" - ), - - prototype = list(values = NULL), - - validity = function(object){ - if (!(is.numeric(object@values) & is.matrix(object@values))){ - return("Expecting numeric matrix") - } - - return(TRUE) - } -) diff --git a/pacehrh/man/PopulationPyramid-class.Rd b/pacehrh/man/PopulationPyramid-class.Rd deleted file mode 100644 index e35183cb..00000000 --- a/pacehrh/man/PopulationPyramid-class.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pace_pop_pyramid_class.R -\docType{class} -\name{PopulationPyramid-class} -\alias{PopulationPyramid-class} -\alias{PopulationPyramid} -\title{Population Pyramid Class} -\value{ -Class of type \code{PopulationPyramid} -} -\description{ -Population Pyramid Class -} -\section{Slots}{ - -\describe{ -\item{\code{length}}{numeric} - -\item{\code{values}}{numeric} -}} - diff --git a/pacehrh/man/TaskParameters-class.Rd b/pacehrh/man/TaskParameters-class.Rd deleted file mode 100644 index 7c3b8e0c..00000000 --- a/pacehrh/man/TaskParameters-class.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pace_task_params_class.R -\docType{class} -\name{TaskParameters-class} -\alias{TaskParameters-class} -\alias{TaskParameters} -\title{Task Parameters Class} -\value{ -Class of type \code{TaskParameters} -} -\description{ -Task Parameters Class -} -\section{Slots}{ - -\describe{ -\item{\code{values}}{numeric matrix} -}} - diff --git a/pacehrh/man/add-PopulationPyramid-PopulationPyramid-method.Rd b/pacehrh/man/add-PopulationPyramid-PopulationPyramid-method.Rd deleted file mode 100644 index caa5261d..00000000 --- a/pacehrh/man/add-PopulationPyramid-PopulationPyramid-method.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pace_add_method.R -\name{add,PopulationPyramid,PopulationPyramid-method} -\alias{add,PopulationPyramid,PopulationPyramid-method} -\title{Add Two PopulationPyramid Objects Together} -\usage{ -\S4method{add}{PopulationPyramid,PopulationPyramid}(obj1, obj2) -} -\arguments{ -\item{obj1}{\code{PopulationPyramid} object} - -\item{obj2}{\code{PopulationPyramid} object} -} -\value{ -Updated \code{PopulationPyramid} object -} -\description{ -Add Two PopulationPyramid Objects Together -} diff --git a/pacehrh/man/add-TaskParameters-TaskParameters-method.Rd b/pacehrh/man/add-TaskParameters-TaskParameters-method.Rd deleted file mode 100644 index cc549d85..00000000 --- a/pacehrh/man/add-TaskParameters-TaskParameters-method.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pace_add_method.R -\name{add,TaskParameters,TaskParameters-method} -\alias{add,TaskParameters,TaskParameters-method} -\title{Add Two TaskParameters Objects Together} -\usage{ -\S4method{add}{TaskParameters,TaskParameters}(obj1, obj2) -} -\arguments{ -\item{obj1}{\code{TaskParameters} object} - -\item{obj2}{\code{TaskParameters} object} -} -\value{ -Updated \code{TaskParameters} object -} -\description{ -Add Two TaskParameters Objects Together -} diff --git a/pacehrh/man/loadInitialPopulation.Rd b/pacehrh/man/loadInitialPopulation.Rd index 54ddeb64..a1a604fa 100644 --- a/pacehrh/man/loadInitialPopulation.Rd +++ b/pacehrh/man/loadInitialPopulation.Rd @@ -10,8 +10,8 @@ loadInitialPopulation(sheetName = "TotalPop") \item{sheetName}{Sheet name from the model input Excel file} } \value{ -List with three \code{PopulationPyramid} objects: -\code{female}, \code{male} and \code{total} +Tibble with three population pyramid fields: +\code{Female}, \code{Male} and \code{Total} } \description{ Read the initial population pyramid from the model inputs Excel file. The diff --git a/pacehrh/man/setFromVector-PopulationPyramid-numeric-method.Rd b/pacehrh/man/setFromVector-PopulationPyramid-numeric-method.Rd deleted file mode 100644 index fb63f59c..00000000 --- a/pacehrh/man/setFromVector-PopulationPyramid-numeric-method.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pace_setFromVector_method.R -\name{setFromVector,PopulationPyramid,numeric-method} -\alias{setFromVector,PopulationPyramid,numeric-method} -\title{Set Pyramid Age Values} -\usage{ -\S4method{setFromVector}{PopulationPyramid,numeric}(object, values) -} -\arguments{ -\item{object}{PopulationPyramid object} - -\item{values}{Vector of values to copy into PopulationPyramid object} -} -\value{ -Updated \code{PopulationPyramid} object -} -\description{ -Set Pyramid Age Values -} diff --git a/pacehrh/tests/testthat/test-pace_pop_pyramid_class.R b/pacehrh/tests/testthat/test-pace_pop_pyramid_class.R deleted file mode 100644 index e948e136..00000000 --- a/pacehrh/tests/testthat/test-pace_pop_pyramid_class.R +++ /dev/null @@ -1,19 +0,0 @@ -library(pacehrh) - -withr::local_dir("..") - -test_that("PopulationPyramid class: create", { - pp <- pacehrh::PopulationPyramid() - testthat::expect_s4_class(pp, "PopulationPyramid") - testthat::expect_equal(length(pp@values), pp@length) - testthat::expect_equal(length(pp@values), length(pacehrh:::GPE$ages)) -}) - -test_that("PopulationPyramid class: bad create", { - # Population vectors default to length = 101 - testthat::expect_error(pp <- - pacehrh::PopulationPyramid(values = replicate(10, 42)), - regexp = "wrong length") -}) - -