Skip to content
Open
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
1 change: 1 addition & 0 deletions base/db/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Fixed

* `arrhenius.scaling.traits()` and `filter_sunleaf_traits()`: both functions returned `NULL` instead of the input `data` unchanged when no matching covariates were found. This caused a hard crash (`argument is of length zero`) in `query.trait.data()` whenever temperature-dependent traits (Vcmax, respiration rates) were queried for species where no temperature covariate was recorded in the database. The documented behaviour ("data with no matching covariates will be unchanged") is now implemented correctly.
* `query.trait.data()`: the `warning()` call for missing trait data was placed after `return(NA)` and therefore never fired. Moved before the return and changed to `logger.warn()` for consistency with the rest of the codebase.

* Refactored `convert.input()` internals into smaller, and hopefully more testable, chunks. No user-visible changes expected.
Expand Down
6 changes: 4 additions & 2 deletions base/db/R/covariate.functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ arrhenius.scaling.traits <- function(data, covariates, temp.covariates, new.temp
#remove temporary covariate column.
data<-data[,colnames(data)!='temp']
} else {
data <- NULL
# No temperature covariates found for any observation; assume all were
# measured at missing.temp (default 25 degC) so scaling is a no-op.
# Return data unchanged rather than NULL, as documented.
}
return(data)
}
Expand All @@ -108,7 +110,7 @@ filter_sunleaf_traits <- function(data, covariates){
# remove temporary covariate column
data <- data[,colnames(data)!='canopy_layer']
} else {
data <- NULL
# No canopy_layer covariate found; return data unchanged rather than NULL.
}
return(data)
}
Expand Down
Loading