Skip to content

Commit

Permalink
make additional arguments an error
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Dec 8, 2024
1 parent e25844e commit 9051136
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 132 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: pomp
Type: Package
Title: Statistical Inference for Partially Observed Markov Processes
Version: 5.11.1.0
Date: 2024-12-07
Version: 6.0.0.0
Date: 2024-12-08
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="[email protected]",comment=c(ORCID="0000-0001-6159-3207")),
person(given=c("Edward","L."),family="Ionides",role="aut",comment=c(ORCID="0000-0002-4190-0174")) ,
person(given="Carles",family="Bretó",role="aut",comment=c(ORCID="0000-0003-4695-4902")),
Expand Down
14 changes: 6 additions & 8 deletions R/pomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,14 @@ pomp_internal <- function (

added.userdata <- list(...)
if (length(added.userdata)>0L) {
pWarn_("The provided ",
ngettext(length(added.userdata),"object","objects")," ",
pStop_("The ",
ngettext(length(added.userdata),"argument","arguments")," ",
paste(sQuote(names(added.userdata)),collapse=","),
ngettext(length(added.userdata)," is"," are"),
" available for use by POMP basic components.\n",
"This option is deprecated: use ",sQuote("userdata"),
" to specify the list of such objects explicitly.\n",
"In a future release, this warning will become an error."
ngettext(length(added.userdata),"is","are"),
" not recognized.\nUse the ",sQuote("userdata"),
" argument to supply extra objects to basic model components.",
" See ",sQuote("?userdata"),"."
)
.userdata[names(added.userdata)] <- added.userdata
}
.userdata[names(userdata)] <- userdata

Expand Down
10 changes: 10 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p'

_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _6._0._0:

• From version 5.8.4, the manner in which extra model elements
(‘userdata’) are supplied has changed. As of that version,
use of the old method generated a warning. As of this
version, an error will be generated. To supply additional
elements (i.e., beyond parameters, latent-state variables,
observations, and covariates) to the basic model components,
provide them as a list via the ‘userdata’ argument.

_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _5._1_1._1:

• A new addition to the C API allows one to easily compute the
Expand Down
8 changes: 8 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
\name{NEWS}
\title{News for package `pomp'}
\section{Changes in \pkg{pomp} version 6.0.0}{
\itemize{
\item From version 5.8.4, the manner in which extra model elements (\code{userdata}) are supplied has changed.
As of that version, use of the old method generated a warning.
As of this version, an error will be generated.
To supply additional elements (i.e., beyond parameters, latent-state variables, observations, and covariates) to the basic model components, provide them as a list via the \code{userdata} argument.
}
}
\section{Changes in \pkg{pomp} version 5.11.1}{
\itemize{
\item A new addition to the C API allows one to easily compute the expectation of the Euler-multinomial.
Expand Down
28 changes: 14 additions & 14 deletions tests/kalman.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ try(enkf(pf,Np=-10))
try(enkf(pf,Np="10b"))
try(enkf(pf,Np=100,emeasure=NULL))
try(enkf(enkf,Np=100,vmeasure=NULL))
try(enkf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
try(enkf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
try(enkf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
try(enkf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
try(enkf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
try(enkf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
try(enkf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL))),Np=100))
try(enkf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
enkf(enkf)
enkf(enkf,Np=100)

Expand All @@ -125,12 +125,12 @@ try(eakf(enkf,Np=-10))
try(eakf(enkf,Np="10b"))
try(eakf(enkf,Np=100,emeasure=NULL))
try(eakf(enkf,Np=100,vmeasure=NULL))
try(eakf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
try(eakf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
try(eakf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
try(eakf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
try(eakf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
try(eakf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
try(eakf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)))
try(eakf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))

invisible(enkf(pf,Np=1000,params=as.list(coef(pf))))
invisible(eakf(pf,Np=1000,params=as.list(coef(pf))))
Expand Down Expand Up @@ -161,11 +161,11 @@ eakf |>
try({
R <- matrix(c(1,0,1,0),2,2)
rownames(R) <- rownames(C)
enkf(pf,Np=1000,R=R)
enkf(pf,Np=1000,userdata=list(R=R))
})

try({
eakf(pf,Np=1000,R=R)
eakf(pf,Np=1000,userdata=list(R=R))
})

try(enkf())
Expand Down
86 changes: 15 additions & 71 deletions tests/kalman.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -140,42 +140,18 @@ In enkf_internal(data, Np = Np, ..., verbose = verbose) :
Error : in 'enkf': 'emeasure' is a needed basic component.
> try(enkf(enkf,Np=100,vmeasure=NULL))
Error : in 'enkf': 'vmeasure' is a needed basic component.
> try(enkf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'C' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(enkf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
Error : in 'enkf': number of observables returned by 'emeasure' does not match data.
In addition: Warning message:
The provided object 'C' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(enkf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL))),Np=100))
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(enkf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
> try(enkf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> enkf(enkf)
<object of class 'kalmand_pomp'>
> enkf(enkf,Np=100)
Expand All @@ -194,42 +170,18 @@ In eakf_internal(data, Np = Np, ..., verbose = verbose) :
Error : in 'eakf': 'emeasure' is a needed basic component.
> try(eakf(enkf,Np=100,vmeasure=NULL))
Error : in 'eakf': 'vmeasure' is a needed basic component.
> try(eakf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
> try(eakf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'C' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(eakf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
> try(eakf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
Error : in 'eakf': number of observables returned by 'emeasure' does not match data.
In addition: Warning message:
The provided object 'C' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(eakf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
> try(eakf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
> try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(eakf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
> try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)))
Error : in 'eakf': argument "Np" is missing, with no default
> try(eakf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
>
> invisible(enkf(pf,Np=1000,params=as.list(coef(pf))))
> invisible(eakf(pf,Np=1000,params=as.list(coef(pf))))
Expand Down Expand Up @@ -292,22 +244,14 @@ In a future release, this warning will become an error.
> try({
+ R <- matrix(c(1,0,1,0),2,2)
+ rownames(R) <- rownames(C)
+ enkf(pf,Np=1000,R=R)
+ enkf(pf,Np=1000,userdata=list(R=R))
+ })
Error : in 'enkf': degenerate 'vmeasure': the leading minor of order 2 is not positive
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
>
> try({
+ eakf(pf,Np=1000,R=R)
+ eakf(pf,Np=1000,userdata=list(R=R))
+ })
Error : in 'eakf': degenerate 'vmeasure': Lapack routine dgesv: system is exactly singular: U[2,2] = 0
In addition: Warning message:
The provided object 'R' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
>
> try(enkf())
Error : in 'enkf': 'data' is a required argument.
Expand Down
7 changes: 6 additions & 1 deletion tests/mif2.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ try(mif2(po,Nmif=2,Np=100,rw.sd=rw_sd(sigma=0.01,X_0=ivp(0.01)),
cooling.fraction.50=0.1,dmeasure=function(log,...)stop("blop")))
try(mif2(po,Nmif=2,Np=100,rw.sd=rw_sd(sigma=0.01,X_0=ivp(0.01)),
cooling.fraction.50=0.1,dmeasure=function(log,...)NA))
try(
mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
cooling.type="hyper",cooling.fraction.50=0.1,
drpocess="oops",
dmeasure=function(log,...)0) -> mf3
)
mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
cooling.type="hyper",cooling.fraction.50=0.1,
drpocess="oops",
dmeasure=function(log,...)0) -> mf3
try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,dmeasure=NULL))
try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,rprocess=NULL))
Expand Down
13 changes: 8 additions & 5 deletions tests/mif2.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,17 @@ loglik: NA
sigma: 0.0996772
tau: 0.1
X_0: 0.990808
> try(
+ mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
+ cooling.type="hyper",cooling.fraction.50=0.1,
+ drpocess="oops",
+ dmeasure=function(log,...)0) -> mf3
+ )
Error : in 'mif2': The argument 'drpocess'is not recognized.
Use the 'userdata' argument to supply extra objects to basic model components. See '?userdata'.
> mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
+ cooling.type="hyper",cooling.fraction.50=0.1,
+ drpocess="oops",
+ dmeasure=function(log,...)0) -> mf3
Warning message:
The provided object 'drpocess' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,dmeasure=NULL))
Error : in 'mif2': 'rprocess', 'dmeasure' are needed basic components.
> try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,rprocess=NULL))
Expand Down
3 changes: 0 additions & 3 deletions tests/pomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ try(data.frame(a=1:10,b=1:10) |> pomp(times=1,t0=11))
try(data.frame(a=1:10,b=1:10) |> pomp(times="a",t0=11))
try(data.frame(a=1:10,b=1:10) |> pomp(times="b",t0=NULL))
try(data.frame(a=1:10,b=1:10) |> pomp(times="a",t0=NA))
stopifnot(data.frame(a=1:10,b=1:10) |>
pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp")
stopifnot(data.frame(a=1:10,b=1:10) |>
pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp")
Expand Down
7 changes: 0 additions & 7 deletions tests/pomp.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ Error : 't0' must be a single number not greater than 'times[1]'.
Error : 't0' must be a single number not greater than 'times[1]'.
> stopifnot(data.frame(a=1:10,b=1:10) |>
+ pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
+ covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp")
Warning message:
The provided object 'bob' is available for use by POMP basic components.
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
In a future release, this warning will become an error.
> stopifnot(data.frame(a=1:10,b=1:10) |>
+ pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
+ covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp")
> try(data.frame(a=1:10,b=1:10) |>
+ pomp(covar=covariate_table(c=1:10,d=1:10,d=1:10,times="c"),
Expand Down
6 changes: 3 additions & 3 deletions tests/spy.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(pomp)

gompertz() -> po

pomp(po,partrans=NULL,bob=3,
pomp(po,partrans=NULL,userdata=list(bob=3),
covar=covariate_table(a=0:20,b=0:20,times="a")) -> po1
spy(po1)

Expand All @@ -29,7 +29,7 @@ try(spy(list()))
pomp(
data=NULL,
t0=0,times=1:10,
x0=as.double(1),
userdata=list(x0=as.double(1)),
params=c(x_0=1,a=22),
rinit=Csnippet(r"{x = *get_userdata_double("x0");}"),
statenames="x",
Expand All @@ -40,7 +40,7 @@ pomp(
pomp(
data=NULL,
t0=0,times=1:10,
x0=as.double(1),
userdata=list(x0=as.double(1)),
params=c(x_0=1,a=22),
globals=Csnippet("static double X0;"),
rinit=Csnippet(r"{x = X0;}"),
Expand Down
Loading

0 comments on commit 9051136

Please sign in to comment.