R Under development (unstable) (2024-09-06 r87103 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > if (file.exists("_options.R")) source("_options.R") > library(panelPomp,quietly=TRUE) > > TESTS_PASS <- NULL > test <- function(expr1,expr2,all="TESTS_PASS",env=parent.frame(),...) + panelPomp:::test(expr1,expr2,all=all,env=env,...) > > ## write rows in r= & columns in c= > m1x1 <- matrix( + paste0(rep(paste0(1:c(r=1),"_"),times=c(c=1)),rep(seq(1,c(c=1)),each=c(r=1))), + nrow=c(r=1),dimnames=list(paste0("r",1:c(r=1)),c(paste0("c",1:c(c=1))))) > m1x2 <- matrix( ## named rownames and colnames! + paste0(rep(paste0(1:c(r=1),"_"),times=c(c=2)),rep(seq(1,c(c=2)),each=c(r=1))), + nrow=c(r=1),dimnames=list(rnm=paste0("r",1:c(r=1)),cnm=c(paste0("c",1:c(c=2))))) > m2x5 <- matrix( + paste0(rep(paste0(1:c(r=2),"_"),times=c(c=5)),rep(seq(1,c(c=5)),each=c(r=2))), + nrow=c(r=2),dimnames=list(paste0("r",1:c(r=2)),c(paste0("c",1:c(c=5))))) > > # tests for get_col > ############################################[rows,col]###############[rows] > test(get_col(m1x1,rows=1,col=1), + setNames(m1x1[rows=1,col=1],nm=rownames(m1x1)[rows=1])) [1] TRUE > test(get_col(m1x2,rows=1,col=1), + setNames(m1x2[rows=1,col=1],nm=rownames(m1x2)[rows=1])) [1] TRUE > test(get_col(m1x2,rows=1,col=1), + setNames(m1x2[rows=1,col=1],nm=rownames(m1x2)[rows=1])) [1] TRUE > test(get_col(m2x5,rows=1,col=1), + setNames(m2x5[rows=1,col=1],nm=rownames(m2x5)[rows=1])) [1] TRUE > test(get_col(m2x5,,col=1),setNames(m2x5[,col=1],nm=rownames(m2x5)[])) [1] TRUE > # tests for get_row > ############################################[rows,col]###############[rows] > test(get_row(m1x1,cols=1,row=1), + setNames(m1x1[row=1,cols=1],nm=colnames(m1x1)[cols=1])) [1] TRUE > test(get_row(m2x5,cols=1,row=1), + setNames(m2x5[row=1,cols=1],nm=colnames(m2x5)[cols=1])) [1] TRUE > test(get_row(m2x5,,row=1),setNames(m2x5[row=1,],nm=colnames(m2x5)[])) [1] TRUE > > ## check whether all tests passed > all(get(eval(formals(test))$all)) [1] TRUE > if (!all(get(eval(formals(test))$all))) stop("Not all tests passed!") > > proc.time() user system elapsed 0.46 0.06 0.53