Skip to content

Commit

Permalink
Merge pull request #213 from metrumresearchgroup/dev
Browse files Browse the repository at this point in the history
Release 0.8.6
  • Loading branch information
kylebaron authored Mar 16, 2017
2 parents ec76cb1 + e199adc commit 261e00a
Show file tree
Hide file tree
Showing 46 changed files with 269 additions and 226 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mrgsolve/
cran-comments.md
Rchecks
.github
Expand Down
Empty file removed .github/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mrgsolve
Type: Package
Version: 0.8.3.9000
Version: 0.8.6
Title: Simulate from ODE-Based Population PK/PD and Systems Pharmacology
Models
Authors@R: c(
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ CHKDIR=Rchecks
## Set libPaths:
##export R_LIBS=${LIBDIR}

gut_check:
Rscript "inst/maintenance/gut_check.R"

pkgdown:
Rscript -e 'library(pkgdown)' -e 'build_home()' -e 'build_reference(examples=FALSE)' -e 'build_news()'

test-all:
Rscript -e 'library(testthat)' -e 'test_dir("tests/testthat")' -e 'test_dir("inst/maintenance/unit")'

unit:
Rscript -e 'library(testthat)' -e 'test_dir("inst/maintenance/unit")'

cran:
make doc
make build
Expand Down Expand Up @@ -53,7 +62,7 @@ check:
make doc
make build
R CMD check ${TARBALL} -o ${CHKDIR}

make unit
qcheck:
make doc
make build
Expand All @@ -67,11 +76,8 @@ check-cran:

test:
R CMD INSTALL ${PKGDIR}
Rscript -e 'library(testthat)' -e 'test_dir("tests/testthat")'
make test-all

.PHONY: tests
tests:
Rscript inst/maintenance/tests.R

clean:
if test -d ${CHKDIR}/mrgsolve.Rcheck; then rm -rf ${CHKDIR}/mrgsolve.Rcheck;fi
Expand All @@ -82,3 +88,4 @@ datasets:
travis:
make build
R CMD check --as-cran ${TARBALL} -o ${CHKDIR}
make test
4 changes: 2 additions & 2 deletions R/library.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ pred_KA = KA*exp(ETA(5));
##'
##' @examples
##'
##' \dontrun{
##' mod <- pkmodel(1)
##'
##' mod %>% ev(amt=1000, ii=24, addl=3) %>% mrgsim(end=120)
##'
##' \dontrun{
##' mod <- pkmodel(1,TRUE)
##' mod <- pkmodel(2)
##' mod <- pkmodel(2,TRUE)
##'
##' }
##'
##'
Expand Down
7 changes: 4 additions & 3 deletions R/mread.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ NULL
##'
##' @examples
##'
##' \dontrun{
##' code <- '
##' $CMT DEPOT CENT
##' $PKMODEL ncmt=1, depot=TRUE
Expand All @@ -42,7 +43,7 @@ NULL
##' '
##'
##' mod <- mcode("example",code)
##'
##' }
##' @export
mcode <- function(model,code, project=tempdir(),...) {
mread(model=model,project=project,code=code,...)
Expand Down Expand Up @@ -94,7 +95,7 @@ mcode <- function(model,code, project=tempdir(),...) {
##'
##' @examples
##'
##'
##' \dontrun{
##' code <- '
##' $PARAM CL = 1, VC = 5
##' $CMT CENT
Expand All @@ -111,7 +112,7 @@ mcode <- function(model,code, project=tempdir(),...) {
##' mod <- mread("irm3", modlib())
##'
##' mod
##'
##' }
mread <- function(model=character(0),project=getwd(),code=NULL,udll=TRUE,
ignore.stdout=TRUE,
raw=FALSE,compile=TRUE,audit=TRUE,
Expand Down
4 changes: 2 additions & 2 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@
##'
##'
##' # Internal model library
##'
##' \dontrun{
##' mod <- mread("irm1", modlib())
##'
##' mod
##'
##' mod %>% ev(amt=300, ii=12, addl=3) %>% mrgsim
##'
##' }
##'
NULL

Expand Down
5 changes: 3 additions & 2 deletions R/simtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@
##' day1 <- c(peak,sparse)
##'
##' design <- c(day1, day1+72, day1+240)
##'
##'
##' \dontrun{
##' mod <- mrgsolve:::house()
##'
##' out <- mod %>% ev(amt=1000, ii=24, addl=10) %>% mrgsim(tgrid=design)
##'
##' plot(out,CP~., type='b')
##'
##' }
tgrid <- function(start=0,end=24,delta=1,add=numeric(0),.offset=0, .scale=1,...) {
new("tgrid", start=start, end=end, delta=delta, add=add, offset=.offset, scale=.scale)
}
Expand Down
2 changes: 2 additions & 0 deletions R/update.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ sval <- unique(c("atol","rtol",
##' @name update
##' @aliases update,mrgmod-method
##' @examples
##' \dontrun{
##' mod <- mrgsolve:::house()
##'
##' mod <- update(mod, end=120, delta=4, param=list(CL=19.1))
##' }
setMethod("update", "mrgmod", function(object,..., merge=TRUE,open=FALSE,data=list()) {

x <- object
Expand Down
8 changes: 4 additions & 4 deletions inst/base/modelheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ struct databox {
// $MAIN, $ODE, and $TABLE get translated into these functions
// We need ODEFUN___ and INITFUN___ and TABLECODE___ defined in the
// .cpp.cpp model file
#define __BEGIN_config__ extern "C" {void __CONFIGFUN___(MRGSOLVE_CONFIG_SIGNATURE) {
#define __BEGIN_config__ extern "C" { void __CONFIGFUN___(MRGSOLVE_CONFIG_SIGNATURE) {
#define __END_config__ __DONE__
#define __BEGIN_ode__ extern "C" {void __ODEFUN___(MRGSOLVE_ODE_SIGNATURE) {
#define __BEGIN_ode__ extern "C" { void __ODEFUN___(MRGSOLVE_ODE_SIGNATURE) {
#define __END_ode__ __DONE__
#define __BEGIN_main__ extern "C" {void __INITFUN___(MRGSOLVE_INIT_SIGNATURE) {
#define __BEGIN_main__ extern "C" { void __INITFUN___(MRGSOLVE_INIT_SIGNATURE) {
#define __END_main__ __DONE__
#define __BEGIN_table__ extern "C" {void __TABLECODE___(MRGSOLVE_TABLE_SIGNATURE) {
#define __BEGIN_table__ extern "C" { void __TABLECODE___(MRGSOLVE_TABLE_SIGNATURE) {
#define __END_table__ __DONE__
#define __DONE__ }}

Expand Down
7 changes: 4 additions & 3 deletions inst/base/mrgsolv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <map>
#include <string>


//! vector of doubles
typedef std::vector<double> dvec;

Expand All @@ -35,7 +36,7 @@ typedef std::vector<std::string > svec;
//! vector of integers
typedef std::vector<int> ivec;

typedef void refun(void*);
typedef void (*refun)(void*);

/**
* @brief Resim functor.
Expand All @@ -46,14 +47,14 @@ typedef void refun(void*);
*/
struct resim {
//! resim constructor
resim(refun* x, void* y) : fun(x), prob(y){}
resim(refun x, void* y) : fun(x), prob(y){}
resim(){}
void operator()() {
return fun(prob);
}

protected:
refun* fun; ///< function to call to re-simulate
refun fun; ///< function to call to re-simulate
void* prob; ///< object to pass to re-simulated function
};

Expand Down
7 changes: 4 additions & 3 deletions inst/include/datarecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ bool CompByTimePosRec(const rec_ptr& a, const rec_ptr& b);
*/
struct CompRec {
inline bool operator()(const rec_ptr& a, const rec_ptr& b) {
if(a->time() == b->time())
return a->pos() < b->pos();
return a->time() < b->time();
if(a->time() == b->time()) {
return a->pos() < b->pos();
}
return a->time() < b->time();
}
};

Expand Down
8 changes: 4 additions & 4 deletions inst/include/modelheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ struct databox {
// $MAIN, $ODE, and $TABLE get translated into these functions
// We need ODEFUN___ and INITFUN___ and TABLECODE___ defined in the
// .cpp.cpp model file
#define __BEGIN_config__ extern "C" {void __CONFIGFUN___(MRGSOLVE_CONFIG_SIGNATURE) {
#define __BEGIN_config__ extern "C" { void __CONFIGFUN___(MRGSOLVE_CONFIG_SIGNATURE) {
#define __END_config__ __DONE__
#define __BEGIN_ode__ extern "C" {void __ODEFUN___(MRGSOLVE_ODE_SIGNATURE) {
#define __BEGIN_ode__ extern "C" { void __ODEFUN___(MRGSOLVE_ODE_SIGNATURE) {
#define __END_ode__ __DONE__
#define __BEGIN_main__ extern "C" {void __INITFUN___(MRGSOLVE_INIT_SIGNATURE) {
#define __BEGIN_main__ extern "C" { void __INITFUN___(MRGSOLVE_INIT_SIGNATURE) {
#define __END_main__ __DONE__
#define __BEGIN_table__ extern "C" {void __TABLECODE___(MRGSOLVE_TABLE_SIGNATURE) {
#define __BEGIN_table__ extern "C" { void __TABLECODE___(MRGSOLVE_TABLE_SIGNATURE) {
#define __END_table__ __DONE__
#define __DONE__ }}

Expand Down
7 changes: 4 additions & 3 deletions inst/include/mrgsolv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <map>
#include <string>


//! vector of doubles
typedef std::vector<double> dvec;

Expand All @@ -35,7 +36,7 @@ typedef std::vector<std::string > svec;
//! vector of integers
typedef std::vector<int> ivec;

typedef void refun(void*);
typedef void (*refun)(void*);

/**
* @brief Resim functor.
Expand All @@ -46,14 +47,14 @@ typedef void refun(void*);
*/
struct resim {
//! resim constructor
resim(refun* x, void* y) : fun(x), prob(y){}
resim(refun x, void* y) : fun(x), prob(y){}
resim(){}
void operator()() {
return fun(prob);
}

protected:
refun* fun; ///< function to call to re-simulate
refun fun; ///< function to call to re-simulate
void* prob; ///< object to pass to re-simulated function
};

Expand Down
20 changes: 12 additions & 8 deletions inst/include/odeproblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ typedef std::vector<rec_ptr> reclist;
typedef std::vector<reclist> recstack;

//! <code>$MAIN</code> function
typedef void init_func(MRGSOLVE_INIT_SIGNATURE);
typedef void (*init_func)(MRGSOLVE_INIT_SIGNATURE);

//! <code>$TABLE</code> function
typedef void table_func(MRGSOLVE_TABLE_SIGNATURE);
typedef void (*table_func)(MRGSOLVE_TABLE_SIGNATURE);

//! <code>$ODE</code> function
typedef void deriv_func(MRGSOLVE_ODE_SIGNATURE);
typedef void (*deriv_func)(MRGSOLVE_ODE_SIGNATURE);

//! <code>$PREAMBLE</code> function
typedef void config_func(MRGSOLVE_CONFIG_SIGNATURE);
typedef void (*config_func)(MRGSOLVE_CONFIG_SIGNATURE);

//! function to hand off to <code>DLSODA</code>
typedef void main_deriv_func(int* neq, double* t,
Expand Down Expand Up @@ -201,6 +201,7 @@ class odeproblem : public odepack_dlsoda {
void copy_parin(const Rcpp::List& parin);
void copy_funs(const Rcpp::List& funs);


protected:

double* Param; ///< model parameters
Expand All @@ -212,10 +213,7 @@ class odeproblem : public odepack_dlsoda {
dvec Init_dummy; ///< initial conditions for user input
dvec F; ///< bioavability
dvec Alag; ///< dosing lag time
deriv_func* Derivs; ///< <code>$ODE</code> function
init_func* Inits; ///< <code>$MAIN</code> function
table_func* Table; ///< <code>$TABLE</code> function
config_func* Config; ///< <code>$PREAMBLE</code> function

std::vector<int> On; ///< compartment on/off indicator
databox d; ///< various data passed to model functions

Expand All @@ -232,6 +230,12 @@ class odeproblem : public odepack_dlsoda {
dvec pred; ///< brings clearances, volumes, and kas for advan 1/2/3/4 calculations
dvec Capture; ///< captured data items

deriv_func Derivs; ///< <code>$ODE</code> function
init_func Inits; ///< <code>$MAIN</code> function
table_func Table; ///< <code>$TABLE</code> function
config_func Config; ///< <code>$PREAMBLE</code> function


};


Expand Down
5 changes: 5 additions & 0 deletions inst/maintenance/gut_check.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source(file.path("inst", "maintenance","maint.R"))
pkg <- satellite_package(all_tests=TRUE)
keepdir <- file.path("Rchecks", "gut_check")
if(!dir.exists(keepdir)) dir.create(keepdir)
devtools::check(basename(pkg),check_dir=keepdir)
20 changes: 20 additions & 0 deletions inst/maintenance/maint.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


satellite_package <- function(all_tests=FALSE,pkgname="mrgsolve") {

tmp <- tempdir()
chkdir <- file.path(tmp,paste0(pkgname,"_check"))
if(dir.exists(chkdir)) unlink(chkdir,recursive=TRUE)

foo <- devtools::build('.')
x <- utils::untar(foo,exdir=chkdir)

if(all_tests) {
xtests <- list.files(file.path("inst","maintenance", "unit"),
full.names=TRUE)
file.copy(xtests,
file.path(chkdir, pkgname, "tests", "testthat"),
overwrite=TRUE)
}
file.path(chkdir,pkgname)
}
Loading

0 comments on commit 261e00a

Please sign in to comment.