Skip to content

Commit

Permalink
bump to 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-navarro committed Mar 12, 2024
1 parent c6c18d0 commit cb92335
Show file tree
Hide file tree
Showing 90 changed files with 1,229 additions and 751 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: calmr
Title: Canonical Associative Learning Models and their Representations
Version: 0.6.0
Version: 0.6.1
Authors@R:
person("Victor", "Navarro", , "[email protected]", role = c("aut", "cre"))
Description: Implementations of canonical associative learning models, with tools to run experiment simulations, estimate model parameters, and compare model representations. Experiments and results are represented using S4 classes and methods.
Expand Down
6 changes: 1 addition & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("parameters<-")
export(calmr_model_graph)
export(calmr_model_plot)
export(calmr_verbosity)
Expand All @@ -14,7 +13,6 @@ export(get_parameters)
export(make_experiment)
export(model_outputs)
export(parameter_info)
export(parse)
export(parse_design)
export(patch_graphs)
export(patch_plots)
Expand All @@ -26,19 +24,17 @@ export(supported_families)
export(supported_models)
export(supported_optimizers)
export(supported_plots)
export(trials)
exportClasses(CalmrDesign)
exportClasses(CalmrExperiment)
exportClasses(CalmrExperimentResult)
exportClasses(CalmrFit)
exportClasses(CalmrModel)
exportClasses(CalmrRSA)
exportClasses(CalmrResult)
exportMethods("parameters<-")
exportMethods(AIC)
exportMethods(BIC)
exportMethods(NLL)
exportMethods(aggregate)
exportMethods(augment)
exportMethods(design)
exportMethods(experiences)
exportMethods(graph)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# calmr 0.6.1
* Added `outputs` argument to `run_experiment()`, `parse()`, and `aggregate()`, allowing the user to parse/aggregate only some model outputs.
* Documentation corrections for CRAN resubmission.

# calmr 0.6.0
* Added dependency on `data.table` resulting in great speedups for large experiments.
* Replaced dependency on `cowplot` with dependency on `patchwork`.
Expand Down
2 changes: 1 addition & 1 deletion R/HD2022.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ HD2022 <- function(v = NULL, # nolint: object_name_linter.
vs = vs,
rs = rs,
as = as,
acts = list(combvs = combvs, chainvs = chainvs)
heidi_acts = list(combvs = combvs, chainvs = chainvs)
)
results
}
2 changes: 1 addition & 1 deletion R/HDI2020.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ HDI2020 <- function(v = NULL, # nolint: object_name_linter.
vs = vs,
rs = rs,
as = as,
acts = list(combvs = combvs, chainvs = chainvs)
heidi_acts = list(combvs = combvs, chainvs = chainvs)
)
results
}
2 changes: 1 addition & 1 deletion R/anccr_helpers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' Set reward parameters for ANCCR model
#' @param parameters A list of parameters, as returned by `get_parameters`
#' @param parameters A list of parameters, as returned by [get_parameters()]
#' @param rewards A character vector specifying the reward stimuli.
#' Default = `c("US")`
#' @return A list of parameters
Expand Down
23 changes: 23 additions & 0 deletions R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,26 @@ is_experiment <- function(object) {
is_design <- function(object) {
inherits(object, "CalmrDesign")
}

#' Sanitize model outputs
#' @param os Given outputs. Character vector
#' @param m A model name
#' @return A character vector
#' @note If os is not NULL, cuts extraneous outputs.
#' @noRd
.sanitize_outputs <- function(os, m) {
moutputs <- model_outputs(m)
if (is.null(os)) {
return(moutputs)
}
# extra parameters
extra <- setdiff(os, moutputs)
throw_warn <- length(extra) > 0
os <- os[!(os %in% extra)]
# final parameters
if (!length(os)) {
stop("Ended with zero outputs after sanitization. Check your outputs.")
}
if (throw_warn) warning("Found unsupported outputs. Trimming...")
os
}
2 changes: 1 addition & 1 deletion R/calmr_verbosity.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' This is just a convenience function.
#' @export
#' @return The list of progressr handlers (invisibly).
#' @note See package `progressr` for further details.
#' @note See package 'progressr' for further details.
calmr_verbosity <- function(verbose) {
if (verbose) {
progressr::handlers("progress")
Expand Down
24 changes: 15 additions & 9 deletions R/class_design.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' S4 class for Calmr designs
#' S4 class for calmr designs
#'
#' @section Slots:
#' \describe{
Expand All @@ -18,8 +18,16 @@ methods::setClass(
),
prototype(augmented = FALSE)
)

#' CalmrDesign methods
#' @description S4 methods for `CalmrDesign` class.
#' @param object A `CalmrDesign` object
#' @name CalmrDesign-methods
NULL
#> NULL

#' @export
#' @return `show()` returns NULL (invisibly).
#' @rdname CalmrDesign-methods
methods::setMethod(
"show", "CalmrDesign",
Expand All @@ -35,27 +43,26 @@ methods::setMethod(
}
)

#' @rdname CalmrDesign-methods
#' @noRd
methods::setGeneric(
"mapping",
function(object) methods::standardGeneric("mapping") # nocov
)
#' CalmrDesign methods
#' @description Methods mapping, and trials, are extractor functions.
#' @param object A CalmrDesign, as returned by parse_design
#' @export
#' @aliases mapping
#' @return `mapping()` returns a list with trial mappings.
#' @rdname CalmrDesign-methods
methods::setMethod(
"mapping", "CalmrDesign",
function(object) object@mapping
)
#' @export
#' @rdname CalmrDesign-methods
#' @noRd
methods::setGeneric(
"trials",
function(object) methods::standardGeneric("trials") # nocov
)
#' @export
#' @return `trials()` returns NULL (invisibly).
#' @rdname CalmrDesign-methods
methods::setMethod(
"trials", "CalmrDesign",
Expand Down Expand Up @@ -91,8 +98,7 @@ methods::setGeneric(
#' @param ... Additional parameters depending on the model.
#' @rdname CalmrDesign-methods
#' @aliases augment
#' @order 1
#' @export
#' @noRd
methods::setMethod("augment", "CalmrDesign", function(object, model, ...) {
if (model %in% c("ANCCR")) {
# creates eventlogs
Expand Down
Loading

0 comments on commit cb92335

Please sign in to comment.