From c8d64921c7823e19bb76776a2afdadf8f5e0932b Mon Sep 17 00:00:00 2001 From: gowerc Date: Tue, 2 Apr 2024 18:08:05 +0100 Subject: [PATCH] Added coercion generics --- NAMESPACE | 7 ++++++ R/generics.R | 54 +++++++++++++++++++++++++++++++++++++++++ man/cmdstan_coercion.Rd | 37 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 R/generics.R create mode 100644 man/cmdstan_coercion.Rd diff --git a/NAMESPACE b/NAMESPACE index c8a6217d..559452fb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/generics.R b/R/generics.R new file mode 100644 index 00000000..663cb859 --- /dev/null +++ b/R/generics.R @@ -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") +} diff --git a/man/cmdstan_coercion.Rd b/man/cmdstan_coercion.Rd new file mode 100644 index 00000000..d2d2b483 --- /dev/null +++ b/man/cmdstan_coercion.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/generics.R +\name{cmdstan_coercion} +\alias{cmdstan_coercion} +\alias{as.CmdStanMCMC} +\alias{as.CmdStanMLE} +\alias{as.CmdStanLaplace} +\alias{as.CmdStanVB} +\alias{as.CmdStanPathfinder} +\alias{as.CmdStanGQ} +\alias{as.CmdStanDiagnose} +\title{Coercion methods for CmdStan objects} +\usage{ +as.CmdStanMCMC(object, ...) + +as.CmdStanMLE(object, ...) + +as.CmdStanLaplace(object, ...) + +as.CmdStanVB(object, ...) + +as.CmdStanPathfinder(object, ...) + +as.CmdStanGQ(object, ...) + +as.CmdStanDiagnose(object, ...) +} +\arguments{ +\item{object}{to be coerced} + +\item{...}{additional arguments} +} +\description{ +These methods are used to coerce objects into \code{cmdstanr} objects. +Primarily intended for other packages to use when interfacing +with \code{cmdstanr}. +}