Skip to content

Commit

Permalink
new 'spy' method for pomps
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Jul 6, 2018
1 parent a9d16a2 commit 4fea9db
Show file tree
Hide file tree
Showing 9 changed files with 375 additions and 8 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ exportClasses(
)

exportMethods(
plot,show,print,coerce,summary,logLik,window,"$",
plot,show,print,spy,
coerce,summary,logLik,window,"$",
pompLoad,pompUnload,
dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton,
dprior,rprior,
Expand Down
2 changes: 1 addition & 1 deletion R/builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ callable.decl <- function (code) {

randomName <- function (size = 4, stem = "") {
paste0(stem,
" Time: ",format(Sys.time(),"%Y-%m-%d %H:%M:%OS3 %z"),
"Time: ",format(Sys.time(),"%Y-%m-%d %H:%M:%OS3 %z"),
" Salt: ",
paste(
format(
Expand Down
1 change: 1 addition & 0 deletions R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ setGeneric("print",function(x,...)standardGeneric("print"))
setGeneric("plot",function(x,y,...)standardGeneric("plot"))
setGeneric("summary",function(object,...)standardGeneric("summary"))
setGeneric("window",function(x,...)standardGeneric("window"))
setGeneric("spy",function(object,...)standardGeneric("spy"))

## constituent components of a 'pomp' object
setGeneric("dmeasure",function(object,...)standardGeneric("dmeasure"))
Expand Down
17 changes: 17 additions & 0 deletions R/pomp_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,20 @@ setMethod(
invisible(NULL)
}
)

setMethod(
"spy",
signature=signature(object="pomp"),
definition=function (object) {
if (length(object@solibs) > 0) {
f <- tempfile()
for (i in seq_along(object@solibs)) {
cat(object@solibs[[i]]$src,file=f)
}
file.show(f)
file.remove(f)
} else {
cat("no C snippets to display\n")
}
}
)
3 changes: 3 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _1._1_7._3
‘probe.match.objfun’ can now gracefully handle a list in the
‘start’ or ‘params’ arguments.

• New ‘spy’ method displays the C snippet file(s) associated
with a ‘pomp’ object.

_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _1._1_7._2:

• The long-deprecated ‘seed’ argument to ‘bsmc’ and ‘bsmc2’ has
Expand Down
1 change: 1 addition & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
\item When altering parameters in a call to \code{probe} on a \code{probed.pomp} object, the new parameters were ignored.
This bug has been fixed.
\item \code{mif2}, \code{pfilter}, \code{probe}, \code{probe.match}, and \code{probe.match.objfun} can now gracefully handle a list in the \code{start} or \code{params} arguments.
\item New \code{spy} method displays the C snippet file(s) associated with a \code{pomp} object.
}
}
\section{Changes in \pkg{pomp} version 1.17.2}{
Expand Down
5 changes: 5 additions & 0 deletions man/pomp_methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
\alias{print-pomp}
\alias{show,pomp-method}
\alias{show-pomp}
\alias{spy}
\alias{spy,pomp-method}
\alias{spy-pomp}
\alias{time,pomp-method}
\alias{time-pomp}
\alias{time<-}
Expand Down Expand Up @@ -52,6 +55,7 @@
oma = c(6, 0, 5, 0), axes = TRUE, \dots)
\S4method{print}{pomp}(x, \dots)
\S4method{show}{pomp}(object)
\S4method{spy}{pomp}(object)
\S4method{states}{pomp}(object, vars, \dots)
\S4method{time}{pomp}(x, t0 = FALSE, \dots)
\S4method{time}{pomp}(object, t0 = FALSE, \dots) <- value
Expand Down Expand Up @@ -178,6 +182,7 @@
By default, \code{start} is the time of the first observation and \code{end} is the time of the last.
}
\item{show}{Displays the \code{pomp} object.}
\item{spy}{Displays any C snippet files associated with a \code{pomp} object.}
\item{print}{Print method.}
\item{plot}{
Plots the data and state trajectories (if the latter exist).
Expand Down
4 changes: 4 additions & 0 deletions tests/verbosity.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ capture.output(invisible(mif(window(ricker,end=10),Nmif=1,Np=1,rw.sd=c(r=1),
transform=TRUE,cooling.fraction.50=1,verbose=TRUE)),
type="message") -> out
stopifnot(sum(grepl("filtering failure at time",out))==5)

spy(ricker)
capture.output(pompExample(dacca)) -> out
spy(dacca)
Loading

0 comments on commit 4fea9db

Please sign in to comment.