Skip to content

Commit

Permalink
related and fix #42
Browse files Browse the repository at this point in the history
  • Loading branch information
anadiedrichs committed Feb 6, 2019
1 parent 78e40be commit 0ddd409
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@ buildFAOTemp <- function(temp,tmin)
#'
predFAO <- function(model,t,dw=NULL){

tmin <- NULL
if(class(model)!="FAOFrostModel"){stop("model should be an object of type FAOFrostModel")}
if(is.null(dw)) return(model@a*t +model@c) #TODO chequear el + c -- porque de usar solo la de temperatura seria el coeficiente w
return(model@a*t + (model@b*dw) +model@c)
if(checkTemp(t))
{
if(is.null(dw))
tmin <- (model@a*t) + model@c
else tmin <- (model@a*t) + (model@b*dw) +model@c

}
return(tmin)
}

#' @title Temperature trend during a frost night.
#' @description
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test004.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ test_that("Check argument errors", {
expect_error(buildFAO(t0,td,y), "Array arguments must have the same length")
})

context("predFAO using buildFAO")

current_temp <- 10
current_dw <- 2
ptmin <- predFAO(model2,current_temp,current_dw)

test_that("Check output ", {
expect_is(ptmin,"numeric")
expect_is(predFAO(model2,current_temp,NULL),"numeric")
})

test_that("Check errors ", {

expect_error(predFAO(NULL,current_temp,current_dw))
expect_error(predFAO(model2,NULL,current_dw))
expect_error(predFAO(new("MdzFrostModel",k = -10, kvector=C(8,-10)),current_temp,current_dw))
})


# test buildFAOTemp
context("buildFAOTemp")

Expand Down

0 comments on commit 0ddd409

Please sign in to comment.