Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
^\.github$
^.*\.Rproj$
^\.Rproj\.user$
^\.positai$
^\.claude$
^codecov\.yml$
^man-roxygen$
^README\.md$
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.Rhistory
.RData
.Ruserdata
.positai
inst/doc
wip/
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Implementation of several components of the Carbon Budget Model of
Canadian Forest Service (v3).
URL:
https://github.com/PredictiveEcology/CBMutils
Version: 2.5.3.9002
Version: 2.5.4.9000
Authors@R: c(
person("Céline", "Boisvenue", email = "celine.boisvenue@nrcan-rncan.gc.ca", role = c("aut", "cre")),
person("Alex M", "Chubaty", email = "achubaty@for-cast.ca", role = c("aut"), comment = c(ORCID = "0000-0001-7146-8135")),
Expand Down Expand Up @@ -42,13 +42,11 @@ Suggests:
exactextractr,
FNN,
qs2,
LandR,
reproducible,
SpaDES.core,
rmarkdown,
testthat
Remotes:
PredictiveEcology/LandR@development,
PredictiveEcology/reproducible@development,
PredictiveEcology/SpaDES.core@development
VignetteBuilder: knitr, rmarkdown
Expand Down
9 changes: 3 additions & 6 deletions R/CBM-DB_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ sppMatch <- function(species, match = c("LandR", "Latin_full", "EN_generic_short

# Read species equivalencies table
if (is.null(sppEquivalencies)){
if (length(find.package("LandR", quiet = TRUE)) == 0) stop("LandR package required")
sppEquivalencies <- LandR::sppEquivalencies_CA
sppEquiv <- data.table::fread("https://github.com/PredictiveEcology/LandR/raw/refs/heads/development/data-raw/sppEquivalencies_CA.csv")
}else{
sppEquiv <- data.table::as.data.table(sppEquivalencies)
}
sppEquiv <- tryCatch(
as.data.table(sppEquivalencies),
error = function(e) stop(
"sppEquivalencies could not be converted to data.table: ", e$message, call. = FALSE))

# Return 0 rows
if (length(species) == 0) return(sppEquiv[0,])
Expand Down
13 changes: 7 additions & 6 deletions tests/testthat/test-Data-CBMsources.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ test_that("CBMsourcePrepInputs", {

inputPath <- file.path(testDirs$temp$outputs, "CBMsourcePrepInputs")

srcCBM <- CBMsourcePrepInputs("CanSIS-ecozone", inputPath = inputPath)
srcCBM <- CBMsourcePrepInputs("StatCan-admin", inputPath = inputPath)
expect_is(srcCBM, "list")
expect_equal(srcCBM$attr, "ecozone")
expect_is(srcCBM$source, "sf")
expect_equal(srcCBM$attr, "admin")
expect_true("admin" %in% names(srcCBM$source))

## Backup test
# srcCBM <- CBMsourcePrepInputs("StatCan-admin", inputPath = inputPath)
## Backup test: this source fails to download sometimes
# srcCBM <- CBMsourcePrepInputs("CanSIS-ecozone", inputPath = inputPath)
# expect_is(srcCBM, "list")
# expect_equal(srcCBM$attr, "admin")
# expect_is(srcCBM$source, "sf")
# expect_equal(names(srcCBM$source), c("admin", "geometry"))
# expect_equal(srcCBM$attr, "ecozone")
# expect_true("ecozone" %in% names(srcCBM$source))
})

test_that("CBMsourceExtractToRast", {
Expand Down
Loading