diff --git a/base/db/NEWS.md b/base/db/NEWS.md index c07db43990..e8d6ff63df 100644 --- a/base/db/NEWS.md +++ b/base/db/NEWS.md @@ -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. diff --git a/base/db/R/covariate.functions.R b/base/db/R/covariate.functions.R index c40e3ca5a0..dd0c3edc11 100644 --- a/base/db/R/covariate.functions.R +++ b/base/db/R/covariate.functions.R @@ -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) } @@ -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) }