[Pomp-commits] r1143 - in pkg/pomp: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 16 13:21:51 CET 2015


Author: kingaa
Date: 2015-03-16 13:21:51 +0100 (Mon, 16 Mar 2015)
New Revision: 1143

Modified:
   pkg/pomp/DESCRIPTION
   pkg/pomp/R/builder.R
Log:
- fix some problems with rendering from templates

Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION	2015-03-15 16:09:02 UTC (rev 1142)
+++ pkg/pomp/DESCRIPTION	2015-03-16 12:21:51 UTC (rev 1143)
@@ -1,8 +1,8 @@
 Package: pomp
 Type: Package
 Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.63-1
-Date: 2015-03-15
+Version: 0.63-2
+Date: 2015-03-16
 Authors at R: c(person(given=c("Aaron","A."),family="King",
 		role=c("aut","cre"),email="kingaa at umich.edu"),
 	  person(given=c("Edward","L."),family="Ionides",role=c("aut")),

Modified: pkg/pomp/R/builder.R
===================================================================
--- pkg/pomp/R/builder.R	2015-03-15 16:09:02 UTC (rev 1142)
+++ pkg/pomp/R/builder.R	2015-03-16 12:21:51 UTC (rev 1143)
@@ -21,7 +21,7 @@
   if (.Platform$OS.type=="windows") {
     stem <- gsub("\\","/",stem,fixed=TRUE)
   }
-  modelfile <- paste0(stem,".c") 
+  modelfile <- paste0(stem,".c")
   solib <- paste0(stem,.Platform$dynlib.ext)
 
   if (.Platform$OS.type=="unix") {
@@ -29,9 +29,9 @@
   } else {
     pompheader <- system.file("include/pomp.h",package="pomp")
   }
-  
+
   out <- file(description=modelfile,open="w")
-  
+
   cat(file=out,render(header$file,name=name,pompheader=pompheader))
 
   for (f in utility.fns) {
@@ -42,24 +42,24 @@
 
   ## variable/parameter/observations definitions
   for (v in seq_along(paramnames)) {
-    cat(file=out,render(define$var,variable=paramnames[v],ptr='__p',ilist='__parindex',index=v-1))
+    cat(file=out,render(define$var,variable=paramnames[v],ptr='__p',ilist='__parindex',index=as.integer(v-1)))
   }
   for (v in seq_along(statenames)) {
-    cat(file=out,render(define$var,variable=statenames[v],ptr='__x',ilist='__stateindex',index=v-1))
+    cat(file=out,render(define$var,variable=statenames[v],ptr='__x',ilist='__stateindex',index=as.integer(v-1)))
   }
   for (v in seq_along(covarnames)) {
-    cat(file=out,render(define$var,variable=covarnames[v],ptr='__covars',ilist='__covindex',index=v-1))
+    cat(file=out,render(define$var,variable=covarnames[v],ptr='__covars',ilist='__covindex',index=as.integer(v-1)))
   }
   for (v in seq_along(obsnames)) {
-    cat(file=out,render(define$var,variable=obsnames[v],ptr='__y',ilist='__obsindex',index=v-1))
+    cat(file=out,render(define$var,variable=obsnames[v],ptr='__y',ilist='__obsindex',index=as.integer(v-1)))
   }
   for (v in seq_along(statenames)) {
-    cat(file=out,render(define$var,variable=paste0("D",statenames[v]),ptr='__f',ilist='__stateindex',index=v-1))
+    cat(file=out,render(define$var,variable=paste0("D",statenames[v]),ptr='__f',ilist='__stateindex',index=as.integer(v-1)))
   }
   for (v in seq_along(paramnames)) {
-    cat(file=out,render(define$var,variable=paste0("T",paramnames[v]),ptr='__pt',ilist='__parindex',index=v-1))
+    cat(file=out,render(define$var,variable=paste0("T",paramnames[v]),ptr='__pt',ilist='__parindex',index=as.integer(v-1)))
   }
-  cat(file=out,render(define$var.alt,variable="lik",ptr='__lik',index=0))
+  cat(file=out,render(define$var.alt,variable="lik",ptr='__lik',index=0L))
 
   ## list of functions to register
   registry <- c("load_stack_incr","load_stack_decr")
@@ -193,6 +193,7 @@
 cleanForC <- function (text) {
   text <- as.character(text)
   text <- gsub("\\.","_",text)
+  text <- gsub("-","_",text)
   text
 }
 
@@ -204,7 +205,7 @@
   short <- which(n==1)
   n <- max(n)
   for (i in short) vars[[i]] <- rep(vars[[i]],n)
-  
+
   retval <- vector(mode="list",length=n)
   for (i in seq_len(n)) {
     tpl <- template
@@ -226,7 +227,7 @@
                          parameter.transform, parameter.inv.transform,
                          rprior, dprior,
                          globals, ..., save = FALSE) {
-  
+
   if (!is.data.frame(data)) stop(sQuote("data")," must be a data-frame")
   obsnames <- names(data)
   obsnames <- setdiff(obsnames,times)



More information about the pomp-commits mailing list