[Pomp-commits] r230 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 10 18:41:45 CEST 2010


Author: kingaa
Date: 2010-05-10 18:41:45 +0200 (Mon, 10 May 2010)
New Revision: 230

Modified:
   pkg/R/euler.R
Log:
- preserve backward compatibility


Modified: pkg/R/euler.R
===================================================================
--- pkg/R/euler.R	2010-05-10 15:36:15 UTC (rev 229)
+++ pkg/R/euler.R	2010-05-10 16:41:45 UTC (rev 230)
@@ -7,22 +7,11 @@
                               tcovar, covar, PACKAGE)
 {
   .Deprecated(new="onestep.sim",package="pomp")
-  if (is.character(step.fun)) {
-    efun <- try(
-                getNativeSymbolInfo(step.fun,PACKAGE)$address,
-                silent=FALSE
-                )
-    if (inherits(efun,'try-error')) {
-      stop("no symbol named ",step.fun," in package ",PACKAGE)
-    }
-  } else if (is.function(step.fun)) {
-    if (!all(c('x','t','params','delta.t','...')%in%names(formals(step.fun))))
-      stop(sQuote("step.fun")," must be a function of prototype ",sQuote("step.fun(x,t,params,delta.t,...)"))
-    efun <- step.fun
-  } else {
-    stop(sQuote("step.fun")," must be either a function or the name of a compiled routine")
-  }
-
+  efun <- pomp.fun(
+                   f=step.fun,
+                   PACKAGE=PACKAGE,
+                   proto="step.fun(x,t,params,delta.t,...)"
+                   )
   .Call(
         euler_model_simulator,
         func=efun,
@@ -50,22 +39,11 @@
                             tcovar, covar, PACKAGE)
 {
   .Deprecated(new="euler.sim",package="pomp")
-  if (is.character(step.fun)) {
-    efun <- try(
-                getNativeSymbolInfo(step.fun,PACKAGE)$address,
-                silent=FALSE
-                )
-    if (inherits(efun,'try-error')) {
-      stop("no symbol named ",step.fun," in package ",PACKAGE)
-    }
-  } else if (is.function(step.fun)) {
-    if (!all(c('x','t','params','delta.t','...')%in%names(formals(step.fun))))
-      stop(sQuote("step.fun")," must be a function of prototype ",sQuote("step.fun(x,t,params,delta.t,...)"))
-    efun <- step.fun
-  } else {
-    stop(sQuote("step.fun")," must be either a function or the name of a compiled routine")
-  }
-
+  efun <- pomp.fun(
+                   f=step.fun,
+                   PACKAGE=PACKAGE,
+                   proto="step.fun(x,t,params,delta.t,...)"
+                   )
   .Call(
         euler_model_simulator,
         func=efun,
@@ -93,22 +71,11 @@
                              PACKAGE)
 {
   .Deprecated(new="onestep.dens",package="pomp")
-  if (is.character(dens.fun)) {
-    efun <- try(
-                getNativeSymbolInfo(dens.fun,PACKAGE)$address,
-                silent=FALSE
-                )
-    if (inherits(efun,'try-error')) {
-      stop("no symbol named ",dens.fun," in package ",PACKAGE)
-    }
-  } else if (is.function(dens.fun)) {
-    if (!all(c('x1','x2','t1','t2','params','...')%in%names(formals(dens.fun))))
-      stop(sQuote("dens.fun")," must be a function of prototype ",sQuote("dens.fun(x1,x2,t1,t2,params,...)"))
-    efun <- dens.fun
-  } else {
-    stop(sQuote("dens.fun")," must be either a function or the name of a compiled routine")
-  }
-
+  efun <- pomp.fun(
+                   f=dens.fun,
+                   PACKAGE=PACKAGE,
+                   proto="dens.fun(x1,x2,t1,t2,params,...)"
+                   )
   .Call(
         euler_model_density,
         efun,



More information about the pomp-commits mailing list