Skip to content

Commit

Permalink
Merge pull request #127 from goldingn/master
Browse files Browse the repository at this point in the history
fixing what the last PR broke
  • Loading branch information
goldingn committed Sep 9, 2015
2 parents 0e6a27e + 5f9925b commit 5c5a0a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions R/zoonHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ RunModels <- function(df, modelFunction, paras, workEnv){
paras),
envir = workEnv)

pred <- ZoonPredict(.model$model,
pred <- ZoonPredict(modelFold,
newdata = df[df$fold == i, 6:NCOL(df), drop = FALSE])

dfOut$predictions[df$fold == i] <- pred
Expand All @@ -175,7 +175,7 @@ RunModels <- function(df, modelFunction, paras, workEnv){
# If external validation dataset exists, predict that;.
if(0 %in% df$fold){

pred <- ZoonPredict(.model$model,
pred <- ZoonPredict(modelFold,
newdata = df[df$fold == 0, 6:NCOL(df), drop = FALSE])

dfOut$predictions[df$fold == 0] <- pred
Expand Down Expand Up @@ -353,7 +353,7 @@ ExtractAndCombData <- function(occurrence, ras){

Chain <- function(...){
ans <- list(...)
attr(ans, 'isChain') <- TRUE
attr(ans, 'chain') <- TRUE
return (ans)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-ChangeWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ test_that('RerunWorkflow works', {

expect_true(all.equal(w1, w2))


})


26 changes: 16 additions & 10 deletions tests/testthat/test-wholeWorkflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ test_that('simple, package data workflow works.', {
expect_equal(names(work1$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(work1$process.output[[1]][[1]]), c(269, 6))
expect_is((work1$model.output[[1]])$model, c('glm', 'lm'))
expect_is((work1$model.output[[1]])$model, c('zoonModel'))
expect_is((work1$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is((work1$model.output[[1]])$data, c('data.frame'))
expect_is(work1$report[[1]], 'RasterLayer')

Expand All @@ -44,7 +45,8 @@ test_that('Check basic quoted workflow.', {
expect_equal(names(work1$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(work1$process.output[[1]][[1]]), c(269, 6))
expect_is((work1$model.output[[1]])$model, c('glm', 'lm'))
expect_is((work1$model.output[[1]])$model, c('zoonModel'))
expect_is((work1$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is((work1$model.output[[1]])$data, c('data.frame'))
expect_is(work1$report[[1]], 'RasterLayer')

Expand Down Expand Up @@ -72,7 +74,8 @@ test_that('modules downloading data work', {
expect_true(all(work2$occurrence.output[[1]][,'latitude'] > 45))
expect_true(all(work2$occurrence.output[[1]][,'type']=='presence'))
expect_is(work2$covariate.output[[1]], 'RasterLayer')
expect_is((work2$model.output[[1]])$model, 'randomForest')
expect_is((work2$model.output[[1]])$model, 'zoonModel')
expect_is((work2$model.output[[1]])$model$model, 'randomForest')
expect_is(work2$report[[1]], 'RasterLayer')
})

Expand Down Expand Up @@ -195,7 +198,8 @@ test_that('simple, crossvalidation workflow works.', {
expect_equal(names(workCross$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(workCross$process.output[[1]]$df), c(269, 6))
expect_is((workCross$model.output[[1]])$model, c('glm', 'lm'))
expect_is((workCross$model.output[[1]])$model, c('zoonModel'))
expect_is((workCross$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is(workCross$report[[1]], 'RasterLayer')

})
Expand Down Expand Up @@ -230,7 +234,8 @@ test_that('chains work.', {
expect_equal(names(chain1$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(chain1$process.output[[1]]$df), c(457, 6))
expect_is((chain1$model.output[[1]])$model, c('glm', 'lm'))
expect_is((chain1$model.output[[1]])$model, c('zoonModel'))
expect_is((chain1$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is(chain1$report[[1]], 'RasterLayer')

expect_true(exists('chain2'))
Expand All @@ -240,7 +245,8 @@ test_that('chains work.', {
expect_equal(names(chain2$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer.1', 'layer.2'))
expect_equal(dim(chain2$process.output[[1]]$df), c(269, 7))
expect_is((chain2$model.output[[1]])$model, c('glm', 'lm'))
expect_is((chain2$model.output[[1]])$model, c('zoonModel'))
expect_is((chain2$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is(chain2$report[[1]], 'RasterLayer')

expect_true(exists('chain4'))
Expand All @@ -250,7 +256,8 @@ test_that('chains work.', {
expect_equal(names(chain4$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(chain4$process.output[[1]]$df), c(269, 6))
expect_is((chain4$model.output[[1]])$model, c('glm', 'lm'))
expect_is((chain4$model.output[[1]])$model, c('zoonModel'))
expect_is((chain4$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is(chain4$report[[1]], 'list')


Expand All @@ -273,10 +280,9 @@ test_that('workflow with mix of syntax works.', {
expect_equal(names(workSyn$process.output[[1]]$df),
c('value', 'type', 'fold', 'longitude', 'latitude', 'layer'))
expect_equal(dim(workSyn$process.output[[1]][[1]]), c(269, 6))
expect_is((workSyn$model.output[[1]])$model, c('glm', 'lm'))
expect_is((workSyn$model.output[[1]])$model, c('zoonModel'))
expect_is((workSyn$model.output[[1]])$model$model, c('glm', 'lm'))
expect_is((workSyn$model.output[[1]])$data, c('data.frame'))
expect_is(workSyn$report[[1]], 'list')

})


0 comments on commit 5c5a0a4

Please sign in to comment.