Skip to content

Commit

Permalink
Merge pull request #943 from gowerc/feature/generics
Browse files Browse the repository at this point in the history
Added coercion generics
  • Loading branch information
jgabry authored Apr 10, 2024
2 parents 1b45e70 + c8d6492 commit ced35d1
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ S3method(as_draws,CmdStanMCMC)
S3method(as_draws,CmdStanMLE)
S3method(as_draws,CmdStanPathfinder)
S3method(as_draws,CmdStanVB)
export(as.CmdStanDiagnose)
export(as.CmdStanGQ)
export(as.CmdStanLaplace)
export(as.CmdStanMCMC)
export(as.CmdStanMLE)
export(as.CmdStanPathfinder)
export(as.CmdStanVB)
export(as_cmdstan_fit)
export(as_draws)
export(as_mcmc.list)
Expand Down
54 changes: 54 additions & 0 deletions R/generics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

#' Coercion methods for CmdStan objects
#'
#' These methods are used to coerce objects into `cmdstanr` objects.
#' Primarily intended for other packages to use when interfacing
#' with `cmdstanr`.
#'
#' @param object to be coerced
#' @param ... additional arguments
#'
#' @name cmdstan_coercion
NULL

#' @rdname cmdstan_coercion
#' @export
as.CmdStanMCMC <- function(object, ...) {
UseMethod("as.CmdStanMCMC")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanMLE <- function(object, ...) {
UseMethod("as.CmdStanMLE")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanLaplace <- function(object, ...) {
UseMethod("as.CmdStanLaplace")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanVB <- function(object, ...) {
UseMethod("as.CmdStanVB")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanPathfinder <- function(object, ...) {
UseMethod("as.CmdStanPathfinder")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanGQ <- function(object, ...) {
UseMethod("as.CmdStanGQ")
}

#' @rdname cmdstan_coercion
#' @export
as.CmdStanDiagnose <- function(object, ...) {
UseMethod("as.CmdStanDiagnose")
}
37 changes: 37 additions & 0 deletions man/cmdstan_coercion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ced35d1

Please sign in to comment.