From 8c483667c1b60754a025f4336ec87aef3e113b7e Mon Sep 17 00:00:00 2001 From: Phil Chalmers Date: Sun, 18 Sep 2016 09:59:11 -0400 Subject: [PATCH] touch up tests --- Makefile | 4 ++++ README.md | 2 ++ tests/testthat/test-GOF.R | 6 +++--- tests/testthat/test-LD.R | 4 ++-- tests/testthat/test-forward.search.R | 20 +++++++++----------- tests/testthat/test-gCD.R | 2 +- tests/testthat/test-obs.resid.R | 20 ++++++++++---------- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index cedf4c1..c8bb04e 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,10 @@ check: build test: Rscript -e 'library("testthat",quietly=TRUE);library("faoutlier",quietly=TRUE);require("methods",quietly=TRUE);test_dir("tests/testthat")' +paralleltest: + Rscript -e 'library("testthat",quietly=TRUE);library("faoutlier",quietly=TRUE);require("methods",quietly=TRUE);setCluster();test_dir("tests/testthat")' + + clean: $(RM) src/*.o $(RM) src/*.so diff --git a/README.md b/README.md index 2a98c27..091914a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Travis-CI Build Status](https://travis-ci.org/philchalmers/faoutlier.svg?branch=master)](https://travis-ci.org/philchalmers/faoutlier) [![](http://www.r-pkg.org/badges/version/faoutlier)](http://www.r-pkg.org/pkg/faoutlier) ![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat) + #faoutlier Tools for detecting and summarize influential cases that diff --git a/tests/testthat/test-GOF.R b/tests/testthat/test-GOF.R index 68f3ea5..209fb38 100644 --- a/tests/testthat/test-GOF.R +++ b/tests/testthat/test-GOF.R @@ -15,8 +15,8 @@ test_that('GOF run', { #------------------------------------------------------------------- suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) - GOFresult <- GOF(holzinger, model) - GOFresult.outlier <- GOF(holzinger.outlier, model) + GOFresult <- suppressWarnings(GOF(holzinger, model)) + GOFresult.outlier <- suppressWarnings(GOF(holzinger.outlier, model)) expect_equal(as.numeric(GOFresult[1:3]), c(-4.945440, -1.943843, -3.330193), tolerance=1e-5) expect_is(GOFresult, 'GOF') @@ -52,7 +52,7 @@ test_that('GOF categorical', { F2 =~ MissNum + MxdArit + OddWrds F3 =~ Boots + Gloves + Hatchts' - GOFresult <- GOF(dat, model, orthogonal=TRUE, ordered=colnames(dat)) + GOFresult <- suppressWarnings(GOF(dat, model, orthogonal=TRUE, ordered=colnames(dat))) expect_is(GOFresult, 'GOF') expect_equal(as.numeric(head(GOFresult)), c(2.392693, -8.217107, -2.637149, -17.303106, 4.298777, -11.997538), diff --git a/tests/testthat/test-LD.R b/tests/testthat/test-LD.R index 548b458..65360a9 100644 --- a/tests/testthat/test-LD.R +++ b/tests/testthat/test-LD.R @@ -15,8 +15,8 @@ test_that('LD run', { #------------------------------------------------------------------- suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) - LDresult <- LD(holzinger, model) - LDresult.outlier <- LD(holzinger.outlier, model) + LDresult <- suppressWarnings(LD(holzinger, model)) + LDresult.outlier <- suppressWarnings(LD(holzinger.outlier, model)) expect_equal(as.numeric(LDresult[1:3]), c(-4.945440, -1.943843, -3.330193), tolerance=1e-5) expect_is(LDresult, 'LD') diff --git a/tests/testthat/test-forward.search.R b/tests/testthat/test-forward.search.R index 63aecf7..dd2d114 100644 --- a/tests/testthat/test-forward.search.R +++ b/tests/testthat/test-forward.search.R @@ -1,25 +1,23 @@ context('forward.search') -setCluster() - -test_that('forward.search run', { +test_that('forward.search run', { set.seed(1234) - + #Exploratory nfact <- 3 FS <- forward.search(holzinger, nfact, print.messages = FALSE) expect_is(FS, 'forward.search') expect_is(plot(FS), 'trellis') expect_equal(FS$GOF[c(1, length(FS$GOF))], c(3.717805, 26.293829), tolerance = 1e-5) - - #------------------------------------------------------------------- - suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) + + #------------------------------------------------------------------- + suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) FS.outlier <- suppressWarnings(forward.search(holzinger.outlier, model, print.messages = FALSE)) expect_is(FS.outlier, 'forward.search') expect_is(plot(FS.outlier), 'trellis') - expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))], + expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))], c(34.64542, 161.01480), tolerance = 1e-5) - + #---- lavaan model <- 'F1 =~ Remndrs + SntComp + WrdMean F2 =~ MissNum + MxdArit + OddWrds @@ -28,7 +26,7 @@ test_that('forward.search run', { p.base = .7) expect_is(FS.outlier, 'forward.search') expect_is(plot(FS.outlier), 'trellis') - expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))], + expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))], c(26.96743, 111.39844), tolerance = 1e-5) - + }) \ No newline at end of file diff --git a/tests/testthat/test-gCD.R b/tests/testthat/test-gCD.R index f8f70e4..ecaa821 100644 --- a/tests/testthat/test-gCD.R +++ b/tests/testthat/test-gCD.R @@ -14,7 +14,7 @@ test_that('gCD run', { #------------------------------------------------------------------- suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) - gCDresult <- gCD(holzinger, model) + gCDresult <- suppressWarnings(gCD(holzinger, model)) gCDresult.outlier <- suppressWarnings(gCD(holzinger.outlier, model)) expect_is(gCDresult, 'gCD') expect_is(plot(gCDresult), 'trellis') diff --git a/tests/testthat/test-obs.resid.R b/tests/testthat/test-obs.resid.R index fc1ed4a..15f7010 100644 --- a/tests/testthat/test-obs.resid.R +++ b/tests/testthat/test-obs.resid.R @@ -1,7 +1,7 @@ context('obs.resid') test_that('obs.resid run', { - + #Exploratory nfact <- 3 ORresult <- obs.resid(holzinger, nfact) @@ -11,24 +11,24 @@ test_that('obs.resid run', { expect_is(ORresult, 'obs.resid') expect_is(ORresult.outlier, 'obs.resid') expect_is(plot(ORresult), 'trellis') - expect_is(plot(ORresult.outlier), 'trellis') - - #------------------------------------------------------------------- - suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) - ORresult <- obs.resid(holzinger, model) - ORresult.outlier <- obs.resid(holzinger.outlier, model) + expect_is(plot(ORresult.outlier), 'trellis') + + #------------------------------------------------------------------- + suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE)) + ORresult <- suppressWarnings(obs.resid(holzinger, model)) + ORresult.outlier <- suppressWarnings(obs.resid(holzinger.outlier, model)) expect_equal(ORresult$std_res[1:3], c(0.2548177, -0.5300287, -1.8518586), tolerance = 1e-5) expect_is(ORresult, 'obs.resid') expect_is(ORresult.outlier, 'obs.resid') expect_is(plot(ORresult), 'trellis') expect_is(plot(ORresult.outlier), 'trellis') - - #------------------------------------------------------------------- + + #------------------------------------------------------------------- model <- 'F1 =~ Remndrs + SntComp + WrdMean F2 =~ MissNum + MxdArit + OddWrds F3 =~ Boots + Gloves + Hatchts' - + obs.resid2 <- obs.resid(holzinger, model, orthogonal=TRUE) obs.resid2.outlier <- obs.resid(holzinger.outlier, model, orthogonal=TRUE) expect_equal(ORresult$std_res[1:3], c(0.2548177, -0.5300287, -1.8518586),