Skip to content

Commit

Permalink
Finalize v6.2.0 + linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dschlaep committed Nov 26, 2024
1 parent 879dd0b commit ea29136
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rSOILWAT2
Version: 6.2.0-9000
Version: 6.2.0
Title: An Ecohydrological Ecosystem-Scale Water Balance Simulation Model
Description: Access to the C-based SOILWAT2 v8.0.1 and functionality for
SQLite-database of weather data.
Expand Down
26 changes: 14 additions & 12 deletions R/D_swWeatherData.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ weather_dataColumns <- function() {
weather_renamedDataColumns <- function() {
rbind(
data.frame(
old = "specHavg_pct", new = "specHavg_gPERkg", v = "6.2.0", fail = TRUE
old = "specHavg_pct", new = "specHavg_gPERkg", v = "6.2.0", fail = TRUE,
stringsAsFactors = FALSE
)
)
}
Expand Down Expand Up @@ -252,18 +253,19 @@ upgrade_weatherColumns <- function(
template_weatherColumns = c("Year", "DOY", weather_dataColumns())
) {
cns <- colnames(weatherDF)
if (any(!cns %in% template_weatherColumns)) {
if (!all(cns %in% template_weatherColumns)) {
rds <- weather_renamedDataColumns()
ids <- match(cns, rds[, "old", drop = TRUE], nomatch = 0L)
for (k in which(ids > 0L)) {
if (isTRUE(rds[ids[[k]], "fail", drop = TRUE])) {
if (!all(is_missing_weather(weatherDF[, cns[[k]], drop = TRUE]))) {
stop(
"Renaming ", shQuote(cns[[k]]), " to ",
shQuote(as.character(rds[ids[[k]], "new", drop = TRUE])),
" failed because of non-missing values."
)
}
if (
isTRUE(rds[ids[[k]], "fail", drop = TRUE]) &&
!all(is_missing_weather(weatherDF[, cns[[k]], drop = TRUE]))
) {
stop(
"Renaming ", shQuote(cns[[k]]), " to ",
shQuote(as.character(rds[ids[[k]], "new", drop = TRUE])),
" failed because of non-missing values."
)
}

cns[[k]] <- as.character(rds[ids[[k]], "new", drop = TRUE])
Expand Down Expand Up @@ -354,8 +356,8 @@ weatherHistory <- function(weatherList = NULL) {
}

validObject_weatherHistory <- function(object) {
res <- lapply(object, function(x) validObject(x))
has_msg <- sapply(res, is.character)
res <- lapply(object, validObject)
has_msg <- vapply(res, is.character, FUN.VALUE = NA)
if (any(has_msg)) {
unlist(res[has_msg])

Check warning on line 362 in R/D_swWeatherData.R

View check run for this annotation

Codecov / codecov/patch

R/D_swWeatherData.R#L362

Added line #L362 was not covered by tests
} else {
Expand Down

0 comments on commit ea29136

Please sign in to comment.