Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/philipdelff/NMdata
Browse files Browse the repository at this point in the history
  • Loading branch information
philipdelff committed Oct 2, 2023
2 parents b20d168 + 7f43eda commit e0e53da
Show file tree
Hide file tree
Showing 35 changed files with 120 additions and 110 deletions.
10 changes: 6 additions & 4 deletions R/NMscanMultiple.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ NMscanMultiple <- function(files,dir,file.pattern,as.fun,...){
lst <- NULL
ncols <- NULL
nrows <- NULL
quiet <- NULL
success <- NULL

### Section end: Dummy variables, only not to get NOTE's in pacakge checks
Expand Down Expand Up @@ -124,9 +123,12 @@ NMscanMultiple <- function(files,dir,file.pattern,as.fun,...){
res.all <- rbindlist(res.all.list[dt.lst[,which(success)]],fill=TRUE)
writeNMinfo(res.all,info.list)

setcolorder(dt.lst,cc(lst,nrows,ncols,success,warning))
cat("\nOverview of model scanning results:\n")
print(dt.lst)
### quiet would have to be looked for in ...
## if(!quiet){
setcolorder(dt.lst,cc(lst,nrows,ncols,success,warning))
cat("\nOverview of model scanning results:\n")
print(dt.lst)
## }

## run as.fun
res.all <- as.fun(res.all)
Expand Down
Binary file removed tests/testthat/testReference/NMscanData14.rds
Binary file not shown.
Binary file removed tests/testthat/testReference/NMscanData15.rds
Binary file not shown.
Binary file removed tests/testthat/testReference/NMscanData20.rds
Binary file not shown.
Binary file removed tests/testthat/testReference/NMscanData22b.rds
Binary file not shown.
Binary file removed tests/testthat/testReference/NMscanData25.rds
Binary file not shown.
Binary file removed tests/testthat/testReference/NMscanData27.rds
Binary file not shown.
Binary file modified tests/testthat/testReference/NMscanData4.rds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/testthat/testReference/NMscanData_14.rds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/testthat/testReference/NMscanData_20.rds
Binary file not shown.
Binary file not shown.
Binary file added tests/testthat/testReference/NMscanData_22b.rds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/testthat/testReference/NMscanData_25.rds
Binary file not shown.
Binary file added tests/testthat/testReference/NMscanData_27.rds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/testthat/testReference/NMscanData_30.rds
Binary file not shown.
Binary file modified tests/testthat/testReference/NMscanData_31.rds
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/testthat/test_NMcheckColnames.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_that("basic",{

file.lst <- system.file("examples/nonmem/xgxr001.lst" ,package="NMdata")

res1 <- NMcheckColnames(file=file.lst)
res1 <- NMcheckColnames(file=file.lst,quiet=TRUE)
## dim(res1)

expect_equal_to_reference(res1,fileRef,version=2)
Expand All @@ -19,7 +19,7 @@ test_that("results as data.frame",{

file.lst <- system.file("examples/nonmem/xgxr001.lst" ,package="NMdata")

res1 <- NMcheckColnames(file=file.lst,as.fun=as.data.frame)
res1 <- NMcheckColnames(file=file.lst,as.fun=as.data.frame, quiet=TRUE)

expect_equal_to_reference(res1,fileRef,version=2)
})
Expand Down
51 changes: 27 additions & 24 deletions tests/testthat/test_NMcheckData.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
context("NMcheckData")

library(data.table)
data.table::setDTthreads(1)

## meta is if x is metadata rather than an NMdata object
fix.time <- function(x,meta=T){
if(meta){
Expand Down Expand Up @@ -34,7 +37,7 @@ test_that("basic",{
fileRef <- "testReference/NMcheckData_1.rds"

pk <- readRDS(file="testData/data/xgxr2.rds")
res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)

expect_equal_to_reference(res,fileRef,version=2)
})
Expand All @@ -43,7 +46,7 @@ test_that("No col.flagn",{
fileRef <- "testReference/NMcheckData_2.rds"

pk <- readRDS(file="testData/data/xgxr2.rds")
res <- NMcheckData(pk,col.flagn=FALSE)
res <- NMcheckData(pk,col.flagn=FALSE, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)
})

Expand All @@ -56,7 +59,7 @@ test_that("Misc findings",{
## a comma in a string - but with FLAG>0
pk[2,ret.4:="3,mg"]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -70,7 +73,7 @@ test_that("TIME with characters",{
pk[,TIME:=as.character(TIME)]
pk[ROW==204,TIME:=paste0(TIME,"p")]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -87,7 +90,7 @@ test_that("Misc findings and dup colname",{
colnames(pk)[22] <- "NAME"
pk[2,ret.4:="3,mg"]

res <- expect_warning(NMcheckData(pk))
res <- expect_warning(NMcheckData(pk, quiet=TRUE))
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -98,7 +101,7 @@ test_that("missing EVID",{
pk <- readRDS(file="testData/data/xgxr2.rds")
pk[,EVID:=NULL]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -109,7 +112,7 @@ test_that("missing ID",{
pk <- readRDS(file="testData/data/xgxr2.rds")
pk[,ID:=NULL]

expect_error( NMcheckData(pk))
expect_error( NMcheckData(pk, quiet=TRUE))
})

test_that("missing MDV",{
Expand All @@ -118,7 +121,7 @@ test_that("missing MDV",{
pk <- readRDS(file="testData/data/xgxr2.rds")
pk[,MDV:=1]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)
## expect_equal(as.data.table(res)[level=="row"],as.data.table(readRDS(fileRef))[level=="row"])
})
Expand All @@ -130,7 +133,7 @@ test_that("With ADDL, no II",{
pk <- readRDS(file="testData/data/xgxr2.rds")
pk[EVID==1,ADDL:=1]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)
})

Expand All @@ -141,7 +144,7 @@ test_that("With II, no ADDL",{
pk <- readRDS(file="testData/data/xgxr2.rds")
pk[EVID==1,II:=24]

res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)
})

Expand All @@ -163,7 +166,7 @@ test_that("ID and row with leading 0",{



res <- NMcheckData(pk)
res <- NMcheckData(pk, quiet=TRUE)
## res
expect_equal_to_reference(res,fileRef,version=2)
})
Expand All @@ -180,7 +183,7 @@ test_that("One covariate varying within ID",{
pk <- readRDS(file="testData/data/xgxr2.rds")

pk[1500,WEIGHTB:=30]
res <- NMcheckData(pk,covs=c("trtact","WEIGHTB","CYCLE","DOSE"))
res <- NMcheckData(pk,covs=c("trtact","WEIGHTB","CYCLE","DOSE"), quiet=TRUE)
## res
expect_equal_to_reference(res,fileRef,version=2)
})
Expand All @@ -201,7 +204,7 @@ test_that("with IOV",{
pk.fed)
pk2[,ROW:=.I]

res <- NMcheckData(pk2,covs.occ=list(PERIOD=c("FED")),cols.num="REE")
res <- NMcheckData(pk2,covs.occ=list(PERIOD=c("FED")),cols.num="REE", quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -218,7 +221,7 @@ test_that("covariates within subsets",{
pk[EVID==1,ASSAY:=c(rep(NA,3),1,rep(NA,.N-4))]

## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,cols.num=list("EVID==0"=c("LLOQ","ASSAY"),"EVID==1"=c("site"),"WEIGHTB"))
res <- NMcheckData(pk,cols.num=list("EVID==0"=c("LLOQ","ASSAY"),"EVID==1"=c("site"),"WEIGHTB"), quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -232,7 +235,7 @@ test_that("numerical coded as char and NA as .",{
pk <- readRDS(file="testData/data/xgxr5.rds")

## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,na.strings=NULL)
res <- NMcheckData(pk,na.strings=NULL, quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)

})
Expand All @@ -246,7 +249,7 @@ test_that("usubjid OK",{
pk[,usubjid:=paste0("100-",ID)]

## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,col.usubjid="usubjid")
res <- NMcheckData(pk,col.usubjid="usubjid", quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)


Expand All @@ -264,7 +267,7 @@ test_that("ID not unique",{


## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,col.usubjid="usubjid")
res <- NMcheckData(pk,col.usubjid="usubjid", quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)


Expand All @@ -283,7 +286,7 @@ test_that("usubjid not unique",{


## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,col.usubjid="usubjid")
res <- NMcheckData(pk,col.usubjid="usubjid", quiet=TRUE)
expect_equal_to_reference(res,fileRef,version=2)
})

Expand All @@ -292,10 +295,10 @@ test_that("no col.flagn",{

pk <- readRDS(file="testData/data/xgxr2.rds")
pk <- pk[FLAG==0]
res1 <- NMcheckData(pk)
res1 <- NMcheckData(pk, quiet=TRUE)

pk[,FLAG:=NULL]
res2 <- NMcheckData(pk)
res2 <- NMcheckData(pk, quiet=TRUE)
expect_equal(res1,res2)
})

Expand All @@ -313,8 +316,8 @@ dups_data <- data.frame(


test_that("check data files without cols.dup, but passed with it",{
no_dup_specified <- NMcheckData(dups_data)
dup_specified <- NMcheckData(dups_data, cols.dup = "DVID")
no_dup_specified <- NMcheckData(dups_data, quiet=TRUE)
dup_specified <- NMcheckData(dups_data, cols.dup = "DVID", quiet=TRUE)

expect_equal(nrow(no_dup_specified), 2)
expect_equal(nrow(dup_specified), 0)
Expand All @@ -329,7 +332,7 @@ test_that("simulation data",{

dt.all <- rbind(dt.dos,dt.sim,fill=T)

res <- NMcheckData(dt.all)
res <- NMcheckData(dt.all, quiet=TRUE)

expect_equal_to_reference(res,fileRef)

Expand All @@ -344,7 +347,7 @@ test_that("empty data set",{


## it finds way too many for ASSAY. Should only find 1.
res <- NMcheckData(pk,col.usubjid="usubjid")
res <- NMcheckData(pk,col.usubjid="usubjid", quiet=TRUE)

expect_equal_to_reference(res,fileRef)
})
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_NMcheckDataFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test_that("Using control stream file",{

file.lst <- "testData/nonmem/xgxr001.lst"

res1a <- NMcheckData(file=file.lst)
res1a <- NMcheckData(file=file.lst,quiet=TRUE)

res1a <- fix.time(res1a,meta=F)
expect_equal_to_reference(res1a,fileRef)
Expand All @@ -46,7 +46,7 @@ test_that("Using control stream file",{
## expect_equal(res.ref[[name]],res1a[[name]])
## })

res1b <- NMcheckData(file=file.lst)
res1b <- NMcheckData(file=file.lst,quiet=TRUE)
res1b <- fix.time(res1b,meta=F)

expect_equal(res1a,res1b)
Expand All @@ -63,6 +63,6 @@ test_that("Input control stream missing",{
fileRef <- "testReference/NMcheckDataFile_02.rds"
file.lst <- "testData/nonmem/xgxr001.lst"

expect_error(NMcheckDataFile(file=file.lst,use.input=F))
expect_error(NMcheckDataFile(file=file.lst,use.input=F,quiet=TRUE))

})
4 changes: 2 additions & 2 deletions tests/testthat/test_NMdata_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ test_that("basic",{

file.lst.2 <- NMdata_filepath("examples/nonmem/xgxr002.lst")

res2 <- NMscanData(file=file.lst.2, check.time = FALSE, merge.by.row=FALSE)
res2 <- NMscanData(file=file.lst.2, check.time = FALSE, merge.by.row=FALSE,quiet=TRUE)

## can't rbind data.frames - cols don't match
expect_error(rbind(res1,res2,fill=T))

NMdataConf(as.fun="data.table")
res1 <- NMscanData(file=file.lst.1, quiet=T, order.columns = F, merge.by.row=FALSE, check.time = FALSE)
res2 <- NMscanData(file=file.lst.2, check.time = FALSE, merge.by.row=FALSE)
res2 <- NMscanData(file=file.lst.2, check.time = FALSE, merge.by.row=FALSE,quiet=TRUE)

expect_equal(is.NMdata(res1),TRUE)

Expand Down
Loading

0 comments on commit e0e53da

Please sign in to comment.