Skip to content

Commit

Permalink
Fix of Frescalo installation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanCarbone committed Apr 10, 2024
1 parent 2fa580b commit 277f59e
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions tests/testthat/testfrescalo.r
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,41 @@ test_that("Test errors", {

temp <- tempfile(pattern = 'dir')
dir.create(temp)
expect_error(frescalo(Data = df1,
expect_error(suppressWarnings(frescalo(Data = df1,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'FOO',
year = 'year',
sinkdir = temp),
sinkdir = temp)),
'FOO is not the name of a column in data')

expect_error(frescalo(Data = df1,
expect_error(suppressWarnings(frescalo(Data = df1,
frespath = frespath,
time_periods = c(1980,1990,1989,1999),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp),
sinkdir = temp)),
'time_periods should be a data.frame')

expect_error(frescalo(Data = df1,
expect_error(suppressWarnings(frescalo(Data = df1,
frespath = frespath,
time_periods = data.frame(start=c(1980,1850),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp),
sinkdir = temp)),
'In time_periods year ranges should not overlap')


expect_error(frescalo(Data = df1,
expect_error(suppressWarnings(frescalo(Data = df1,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp),
sinkdir = temp)),
'the sites in your data do not match those in your weights file')

})
Expand All @@ -113,14 +113,14 @@ test_that("Runs without error", {
temp <- tempfile(pattern = 'dir')
dir.create(temp)
sink(file.path(temp, 'null'))
fres_try <- frescalo(Data = df1,
fres_try <- suppressWarnings(frescalo(Data = df1,
Fres_weights = weights,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp)
sinkdir = temp))
sink()
unlink(temp, recursive = TRUE)

Expand All @@ -134,7 +134,7 @@ test_that("Runs without error", {

dir.create(temp)
sink(file.path(temp, 'null'))
fres_try <- frescalo(Data = df1,
fres_try <- suppressWarnings(frescalo(Data = df1,
Fres_weights = weights,
start_col = 'startdate',
end_col = 'enddate',
Expand All @@ -143,7 +143,7 @@ test_that("Runs without error", {
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp)
sinkdir = temp))
sink()
unlink(temp, recursive = TRUE)

Expand All @@ -159,15 +159,15 @@ test_that("Runs without error", {
temp <- tempfile(pattern = 'dir')
dir.create(temp)
sink(file.path(temp, 'null'))
fres_try <- frescalo(Data = df1,
fres_try <- suppressWarnings(frescalo(Data = df1,
phi = 0.51,
Fres_weights = weights,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp)
sinkdir = temp))
sink()
unlink(temp, recursive = TRUE)

Expand All @@ -181,7 +181,6 @@ test_that("Runs without error", {

})


# Create data
n <- 1500 #size of dataset
nyr <- 20 # number of years in data
Expand Down Expand Up @@ -226,16 +225,15 @@ test_that("Test plotting", {
temp <- tempfile(pattern = 'dir')
dir.create(temp)
sink(file.path(temp, 'null'))
fres_try <- frescalo(Data = df1,
fres_try <- suppressWarnings(frescalo(Data = df1,
Fres_weights = weights,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
plot_fres = TRUE,
sinkdir = temp)
)
sinkdir = temp))
sink()
unlink(temp, recursive = TRUE)

Expand Down Expand Up @@ -293,15 +291,15 @@ test_that("Runs high value of phi", {
temp <- tempfile(pattern = 'dir')
dir.create(temp)
sink(file.path(temp, 'null'))
fres_try <- frescalo(Data = df1,
fres_try <- suppressWarnings(frescalo(Data = df1,
Fres_weights = weights,
phi = NULL,
frespath = frespath,
time_periods = data.frame(start=c(1980,1990),end=c(1989,1999)),
site_col = 'site',
sp_col = 'taxa',
year = 'year',
sinkdir = temp)
sinkdir = temp))
sink()
unlink(temp, recursive = TRUE)

Expand Down

0 comments on commit 277f59e

Please sign in to comment.