-
Notifications
You must be signed in to change notification settings - Fork 4
Update test-canopy_service_test.R #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,32 @@ | ||
| ################################################# | ||
| #Tests para canopy_service_test | ||
| ################################################# | ||
|
|
||
| #library(testthat) | ||
| test_that("canopy_service_test data.frame with correct columns", { | ||
|
|
||
| #load data | ||
| mypath<-getwd() | ||
| download_RN() # Run only the first time you use the package. | ||
| setwd(mypath) | ||
| RecruitNet <-read.csv("RecruitNet.csv") | ||
| CanopyCover <-read.csv("CanopyCover.csv") | ||
| res <- canopy_service_test(Amoladeras_int, Amoladeras_cover) | ||
|
|
||
| mysite_com <- comm_subset_UNI(RecruitNet, "Amoladeras") | ||
| mysite_cov <- comm_subset_UNI(CanopyCover, "Amoladeras") | ||
|
|
||
| #------------------------------------ | ||
|
|
||
| test_that("canopy_service_test devuelve un data.frame con las columnas correctas", { | ||
|
|
||
| res <- canopy_service_test(mysite_com, mysite_cov) | ||
|
|
||
| expect_s3_class(res, "data.frame") | ||
|
|
||
| expect_equal( | ||
| colnames(res), | ||
| c("Canopy", "Fc", "Ac", "Fro", "Ao", | ||
| "testability", "Significance", "Test_type", "Canopy_effect") | ||
| ) | ||
|
|
||
| expect_equal(nrow(res), 23) | ||
| }) | ||
|
|
||
|
|
||
| #------------------------------------ | ||
|
|
||
| test_that("Valores agregados correctos para Artemisia_barrelieri", { | ||
| res <- canopy_service_test(mysite_com, mysite_cov) | ||
| test_that("Aggregated values correct for Artemisia_barrelieri", { | ||
|
|
||
| res <- canopy_service_test(Amoladeras_int, Amoladeras_cover) | ||
|
|
||
| fila <- res[res$Canopy == "Artemisia_barrelieri", ] | ||
|
|
||
| expect_equal(fila$Fc, 18) | ||
| expect_equal(fila$Fc, sum(mysite_com[mysite_com$Canopy=="Artemisia_barrelieri" ,"Frequency"])) | ||
| expect_equal(fila$Fc, sum(Amoladeras_int[Amoladeras_int$Canopy=="Artemisia_barrelieri" ,"Frequency"])) | ||
| expect_equal(fila$Fro, 5111) | ||
| expect_equal(fila$Fro, sum(mysite_com[mysite_com$Canopy=="Open" ,"Frequency"])) | ||
| expect_equal(fila$Fro, sum(Amoladeras_int[Amoladeras_int$Canopy=="Open" ,"Frequency"])) | ||
|
Comment on lines
24
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These assertions are a bit confusing as they test expect_equal(fila$Fc, 18)
expect_equal(sum(Amoladeras_int[Amoladeras_int$Canopy=="Artemisia_barrelieri" ,"Frequency"]), 18)
expect_equal(fila$Fro, 5111)
expect_equal(sum(Amoladeras_int[Amoladeras_int$Canopy=="Open" ,"Frequency"]), 5111) |
||
| expect_equal(fila$Ac, 1,tolerance = 1e-6) | ||
| expect_equal(fila$Ao, 6927,tolerance = 1e-6) | ||
|
|
||
|
|
@@ -53,18 +36,19 @@ test_that("Valores agregados correctos para Artemisia_barrelieri", { | |
|
|
||
| #-------------------------------------- | ||
|
|
||
| test_that("Clasificación Canopy_effect correcta para especies conocidas", { | ||
| res <- canopy_service_test(mysite_com, mysite_cov) | ||
| test_that("Clasification Canopy_effect correct for known species", { | ||
|
|
||
| res <- canopy_service_test(Amoladeras_int, Amoladeras_cover) | ||
|
|
||
| expect_equal( | ||
| res$Canopy_effect[res$Canopy == "Artemisia_barrelieri"], | ||
| "Facilitative" | ||
| ) | ||
|
|
||
| expect_equal( | ||
| res$Canopy_effect[res$Canopy == "Artemisia_campestris"], | ||
| "Neutral" | ||
| ) | ||
| }) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.